Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions web/js/MonitorStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function MonitorStream(monitorData) {
request: 'stream',
connkey: this.connKey
};
this.fatalError = false;
this.playerPriority = {
1: { // This setting should always be priority #1.
name: 'default',
Expand Down Expand Up @@ -591,6 +592,7 @@ function MonitorStream(monitorData) {
};

this.start = function(streamChannel = 'default') {
this.fatalError = false;
this.writeTextInfoBlock("Loading...");
this.go2rtcTranscodeTried = false; // a fresh start re-probes the native stream first
if (streamChannel === null || streamChannel === '' || currentView == 'montage') streamChannel = 'default';
Expand Down Expand Up @@ -866,10 +868,29 @@ function MonitorStream(monitorData) {

this.restart = function(channelStream = "default", delay = 200) {
this.stop();
const this_ = this;
setTimeout(function() {// During the downtime, the monitor may have already started to work.
if (!this_.started) this_.start(channelStream);
}, delay);
const countErrors = this.getCountStreamErrors(this.player);
if (countErrors < this.limitCountErrors) {
setTimeout(function(self) {// During the downtime, the monitor may have already started to work.
if (!self.started) self.start(channelStream);
}, delay, this);
} else {
if (typeof streamCmdStop === 'function') {
// Let's set the correct state for the player control buttons (for example, on the Watch page)
streamCmdStop();
}

if (-1 !== this.player.indexOf('zms')) {
this.writeTextInfoBlock("Error", {showImg: false});
} else {
this.writeTextInfoBlock("Error");
}
this.updateStreamInfo('', 'Error');
this.fatalError = true;
this.resetCountStreamErrors(this.player);
const msg = `Out of ${this.limitCountErrors} consecutive attempts to start a stream for monitor ID=${this.id} using player "${this.player}", none were successful. The stream has been stopped.`;
console.warn(msg);
this.showText(msg);
}
};

this.pause = function() {
Expand Down
5 changes: 3 additions & 2 deletions web/skins/classic/views/js/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1210,8 +1210,9 @@ var cycleIntervalId;
var secondsToCycle = 0;

function nextCycleView() {
secondsToCycle --;
if (secondsToCycle<=0) {
const stream = (monitorStream) ? monitorStream.getAVStream() : null;
if (stream && stream.readyState >= 2 || -1 !== monitorStream.activePlayer.indexOf('zms')) secondsToCycle --;
if (secondsToCycle<=0 || (monitorStream.fatalError && monitorStream.selectedPlayer)) {
cycleNext();
}
$j('#secondsToCycle').text(secondsToCycle);
Expand Down
Loading