• How to loop a pre-roll until a live stream starts (LoopUntilLive)

    By creating a server-side stream, you can loop another video as a filler video in place of a live stream that isn't available. For this to work, you must create a server-side stream that has the video that will be used in place of the live stream. Then you can use the Stream Publisher ModuleLoopUntilLive application module for Wowza Streaming Engine™ media server software to detect when the live stream is available and switch from the filler video to the live stream. When the live stream ends, it will switch back to the filler video.

    Contents

    Prerequisites
    Installation
    Configuration
    Properties
    For developers
    More resources

    Prerequisites


    Wowza Streaming Engine 4.0.0 or later is required.

    At least one server-side stream must be configured on the Streaming Engine live application. There are various methods to do this; however, this article shows how to do this by using a single stream that's configured by following the instructions in How to schedule streaming with Wowza Streaming Engine (StreamPublisher).

    You can also create server-side streams by using the Streams API. See How to do basic server-side publishing with Stream class streams.

    Note: This module uses an internal Application Instance level property to reference each of the server-side streams created by the Stream Publisher. If you use the Streams API to create a server-side stream, then your implementation must create this property when the stream is created and remove it when the stream is closed.

    Name: <name of the server side stream>
    Value: <The Stream class instance>
    Type: com.wowza.wms.stream.publish.Stream

    Installation


    1. Download wse-plugin-streampublisher.zip.

    2. Extract the contents from the downloaded (zipped) package, and then copy the lib/wse-plugin-streampublisher.jar file from the package to the lib folder in your Wowza Streaming Engine installation ([install-dir]/lib).

    3. Restart Wowza Streaming Engine.

    Note: The ModuleLoopUntilLive application module is included in the StreamPublisher module download package. StreamPublisher lets you use a server listener and application module to create a schedule of streams and playlists. For more information, see How to schedule streaming with Wowza Streaming Engine (StreamPublisher).

    Configuration


    To enable this module, add the following module definition to your application. See Configure modules for details.
    Name
    Description
    Fully Qualified Class Name
    ModuleLoopUntilLive Loops filler video until live video is available. com.wowza.wms.plugin.streampublisher.ModuleLoopUntilLive

    Properties


    After enabling the module, you can adjust the default settings by adding the following properties to your application. See Configure properties for details.
    Path
    Name
    Type
    Value
    Notes
    /Root/Application loopUntilLiveSourceStreams String myStream See Notes below. This is the list of live source streams that are published to the application. The source can be a single stream name or a comma-separated list of names (for example: myStream, myOtherStream). (default: myStream)
    /Root/Application loopUntilLiveOutputStreams String Stream1 See Notes below. This is the list of server-side streams created by the Stream Publisher. The source can be a single stream name or a comma-separated list of names (for example: Stream1, Stream2). (default: Stream1)
    /Root/Application loopUntilLiveReloadEntirePlaylist Boolean true (Optional) If the server-side stream has multiple items, setting to true ensures that all items are reloaded and that playback starts from the next item in the list. If set to false, only the item that was playing at the time the live stream started is reloaded. (default: true)
    /Root/Application loopUntilLiveHandleMediaCasters Boolean true (Optional) If the live stream is a MediaCaster stream, special care is needed to ensure that it switches at the correct time when the MediaCaster is ready and receiving a stream. Setting to true ensures that this happens. If set to false, the switch occurs when the MediaCaster is created and will switch back after it's destroyed. (default: true)

    Notes:
    • The loopUntilLiveSourceStreams and loopUntilLiveOutputStreams properties must include the same number of names in each list. The first name in each list will map to the first name in the other list, the second will map to the second, and so on. This allows you to configure multiple source and output streams for an application.

    • The stream names listed in the loopUntilLiveOutputStreams property are used for playback.

    Stream Publisher configuration


    The following example SMIL file is used by the Stream Publisher to create a single output stream called Stream1. (For more information, see How to schedule streaming with Wowza Streaming Engine (StreamPublisher).) It will play sample.mp4 in a loop. When a live source stream (myStream) is published, the output stream will switch to the live source if the previous source used ModuleLoopUntilLive and the default settings shown above.
    <smil>
        <head>
        </head>
        <body>
    
            <stream name="Stream1"></stream>
            
            <playlist name="pl1" playOnStream="Stream1" repeat="true" scheduled="2009-12-11 16:00:00">
                <video src="mp4:sample.mp4" start="0" length="20"/>
            </playlist>
        </body>
    </smil>

    For developers


    Source code is available on GitHub.

    Wowza Media Systems™ provides developers with a platform to create streaming applications and solutions. See Wowza Developer Tools to learn more about our APIs and SDK.

    More resources

    How to schedule streaming with Wowza Streaming Engine (StreamPublisher)

    How to do basic server-side publishing with Stream class streams
    Wowza media server software and all components, including modules, source code, and other related items offered on this page, are copyrighted (c) 2006-2016 by Wowza Media Systems, LLC, all rights reserved, and are licensed pursuant to the Wowza Media Software End User License Agreement.
    Originally Published: 11-02-2012.
    Updated: For Wowza Streaming Engine on 04-18-2016.

    If you're having problems or want to discuss this article, post in our forum.