web.streamOpen

Opens a media stream.

ExampleStream Functions

Syntax

web.streamOpen({object});

JavaScript Object

{  
   id:<string>,
   url:<string>,
   protocol:<string>,
   bandwidth:<value>,
   streamBufferingTimeout:<value>,
   dumpPath:<path>,
   eventReportCB:<string>
   adaptiveMode:<value>	
}
Property Name Description
idThis identifier is used in other functions to specify the stream the functions act on.
urlThe full absolute address of the media.
protocolThe communications protocol. One of HTTP or HLS.
bandwidthThe expected bandwidth. If 0, the Runtime Setting is used.
streamBufferingTimeout

The timeout in seconds from the beginning of the download until it is possible to begin play. If timed out, the web.streamPlay call is aborted with a failed status.

This argument overrides the runtime setting Streaming > Time out for video buffering.

dumpPath Path for downloading streaming file.
eventReportCB See Web Stream Event CallbackThe name of a user-coded callback function to report events.
AdaptiveMode0 for OFF (default) and 1 for ON. If set to ON, HLS (HTTP Live Streaming) video segments are downloaded only when being played. By default, AdaptiveMode is set to OFF and all HLS video segments are downloaded from the beginning of stream play. (Option available from version 2021 R1)

Return Values

Not applicable

Parameterization

Standard parameterization is not available for this function.

General Information

The web.streamOpen function opens a media stream.

The event report callback is invoked zero or more times when events occur.

This function is not recorded. You can insert it manually into your script.

Example

This is an example of a web streaming script:

The following examples implement the basic streaming flow skeleton:Play the movie from the beginning (the entire movie duration is XXX).
web.streamPlay( { id : n, playingDuration : XXX } );Pause the movie.
web.streamPause( { id : n, pausingDuration : XXX } );Stop the movie.
web.streamStop( { id : n } ); HTTPfunction Action(){    //Open an HTTP stream
    web.streamOpen(
        {
            id : 1,
            url : 'http://myhost/streaming-test/video/tiny.mp4',
            protocol : 'HTTP'
        }
    );    //Play for 10s
    web.streamPlay( { id : 1, playingDuration : 10 } );
        //Pause for 5s
    web.streamPause( { id : 1, pausingDuration : 5 } );
        //Seek to 00:00:20
    web.streamSeek( { id : 1, timeOffset : 20 } );    //Change the speed to 1.5
    web.streamSetParamDouble('1',web.SPEED, 1.5);    //Play for 10s
    web.streamPlay( { id : 1, playingDuration : 10 } );    //Get bytes received
    var bytes = web.streamGetParamInt('1',web.BYTES_RECEIVED);    //Close streaming
    web.streamClose(
        {
            id : 1
        }
    );     return 0;