Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

If WebRTC stream playback is stopped by some reason, it can be restored automatically by tweaking player code as follows

var retryToRestartTimeout = 3000; //ms
var addMilesecondsToRestartTryOnEveryFailed = 1000; //ms
var retryMaxTimes = 100;
var retryCount = 0;
var isManualStopped = false;
...
function playStream() {
    var session = Flashphoner.getSessions()[0];
    ...
    stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) {
        ...
    }).on(STREAM_STATUS.FAILED, function () {
        console.log("streamStatus",stream.status());

        setStatus(STREAM_STATUS.FAILED);
        onStopped();
        //try to restart
        retryToRestart();
    });
    stream.play();
}
...
function retryToRestart(){
    if (retryCount < retryMaxTimes){
        setTimeout(function(){
            if (stream   && (stream.status() != STREAM_STATUS.PLAYING)){
                playStream();
                retryToRestartTimeout = retryToRestartTimeout + addMilesecondsToRestartTryOnEveryFailed;
                retryCount++;
            }
        },retryToRestartTimeout);
    }
}
  • No labels