Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The player shows how to convert stream published on WCS server to HLS and play it in browser. HLS stream cut starts automatically when strea is requested by HLS URL, for example https://demo.flashphoner.com:8445/test/test.m3u8 on the screenshot below

The code of the example

...

Where host is WCS server address

Analyzing the code of the example

Toanalize To analize the code get hls-player.js file version with hash 51703a2, which is available here and can be downloaded in build 0.5.28.2753.141.

...

3. Stream name detection (the stream should be published to server)

encodeURIComponent() code

Code Block
languagejs
themeRDark
function playBtnClick() {
    if (validateForm()) {
        var streamName = $('#playStream').val();
        streamName = encodeURIComponent(streamName);
        ...
    }
}

...

If authentication key and token are set, they will be inclueded included to stream URL

Code Block
languagejs
themeRDark
function playBtnClick() {
    if (validateForm()) {
        ...
        var videoSrc = $("#urlServer").val() + '/' + streamName + '/' + streamName + '.m3u8';
        var key = $('#key').val();
        var token = $("#token").val();
        if (key.length > 0 && token.length > 0) {
            videoSrc += "?" + key + "=" + token;
        }
        player.src({
            src: videoSrc,
            type: "application/vnd.apple.mpegurl"
        });
        console.log("Play with VideoJs");
        player.play();
        onStarted();
    }
}

...