Resume the Stream Automatically

dkuo

New Member
Hello,
We have Web Call Server running on a Ubuntu media server that streams live videos from an IP camera. Whenever the network connection is disconnected and reconnected, the video will turn to a dark screen with a play button in the middle. Is there a way to resume the stream automatically as soon as it is reconnected to the media server?
 

Max

Administrator
Staff member
Hello.
You can modify the source code of Embed Player (that you probably use) to automatically restart playback, for example:
Code:
    stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) {
        ...
    }).on(STREAM_STATUS.PLAYING, function (stream) {
        ...
    }).on(STREAM_STATUS.STOPPED, function () {
        console.log("streamStatus",stream.status());
        setStatus(STREAM_STATUS.STOPPED);
        onStopped();
        //try to restart
        if (!isManualStopped) {
            retryToRestart();
        }
    }).on(STREAM_STATUS.FAILED, function () {
        console.log("streamStatus",stream.status());
        setStatus(STREAM_STATUS.FAILED);
        onStopped();
        //try to restart
        retryToRestart();
    }).on(STREAM_STATUS.NOT_ENOUGH_BANDWIDTH, function (stream) {
       ...
    });
    stream.play();

function retryToRestart(){
    if (retryCount < retryMaxTimes){
        setTimeout(function(){
            if (stream
                && (stream.status() != STREAM_STATUS.PLAYING)){
                start();
                retryToRestartTimeout = retryToRestartTimeout + addMilesecondsToRestartTryOnEveryFailed;
                retryCount++;
            }
        },retryToRestartTimeout);
    }
}
 

dkuo

New Member
Hi Max,
Thank you for your reply, but which file do I modify and where can I find this file?
 

Max

Administrator
Staff member
Embed Player source files are placed in WCS_HOME/client2/examples/demo/streaming/embed_player folder, you should modify player.js file.
 

dkuo

New Member
Hi Max,
I made the changes you posted, but now it's not streaming. I've tried reverting the the file, but it still doesn't work. I've even reinstalled Web Call Server, but now I just get a "...took too long to respond" message.
upload_2018-11-12_11-10-23.png

We just open the IP stream in an iframe, like this:
<iframe id="fp_embed_player" ... ng-src="http://ServerIP:9091/embed_player?u...s=WebRTC,Flash,MSE,WSPlayer&amp;autoplay=true"></iframe>

Any idea why it would stop working?

Regards,
David K.
 
Top