Skip to content

Commit 3356c06

Browse files
authored
Correct switching of players and stream channels (watch.js)
1 parent 989b4a8 commit 3356c06

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

web/skins/classic/views/js/watch.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -834,11 +834,10 @@ function streamStart(monitor = null) {
834834
monitorStream.setup_volume(document.getElementById('volume'));
835835
monitorStream.setup_mute(document.getElementById('mute'));
836836

837-
monitorStream.setPlayer(player);
837+
monitorStream.setPlayer($j('#player').val());
838838
monitorStream.setBottomElement(document.getElementById('dvrControls'));
839-
// Managing the visibility of elements
840-
manageStreamQualityVisibility();
841-
839+
monitorStream.manageAvailablePlayers();
840+
setChannelStream();
842841
// Start the fps and status updates. give a random delay so that we don't assault the server
843842
//monitorStream.setScale($j('#scale').val(), $j('#width').val(), $j('#height').val());
844843
//monitorsSetScale(monitorId);
@@ -864,6 +863,7 @@ function streamStart(monitor = null) {
864863
forceAlmBtn.prop('title', forceAlmBtn.prop('title') + ': disabled because cannot edit Monitors');
865864
enableAlmBtn.prop('title', enableAlmBtn.prop('title') + ': disabled because cannot edit Monitors');
866865
}
866+
manageStreamQualityVisibility(); // In order for the Auto mode AFTER the start to register the player value .activePlayer and based on this we select the correct "Stream quality", i.e. either the quality for ZMS, or the channel for go2rtc/RTSP2Web
867867
}
868868

869869
function streamReStart(oldId, newId) {
@@ -905,27 +905,39 @@ function streamReStart(oldId, newId) {
905905

906906
table.bootstrapTable('destroy');
907907
applyMonitorControllable();
908-
manageChannelStream();
908+
//manageChannelStream();
909909
streamPrepareStart(currentMonitor);
910910
zmPanZoom.init();
911911
zmPanZoom.init({objString: '.imageFeed', disablePan: true, contain: 'inside', additional: true});
912912
//document.getElementById('monitor').classList.remove('hidden-shift');
913913
}
914914

915-
function manageStreamQualityVisibility() {
916-
const streamQuality = document.getElementById('streamQuality');
915+
function setChannelStream() {
917916
const streamChannel = document.getElementById('streamChannel');
918-
const rateControl = document.getElementById('rateControl');
917+
manageChannelStream();
919918

920-
if ((monitorStream.player) && (-1 !== monitorStream.player.indexOf('go2rtc') || -1 !== monitorStream.player.indexOf('rtsp2web'))) {
921-
let streamChannelValue = (getCookie('zmStreamChannel') || currentMonitor.RTSP2WebStream);
919+
if (-1 === monitorStream.activePlayer.indexOf('zms')) {
920+
let streamChannelValue = (getCookie('zmStreamChannel') || currentMonitor.RTSP2WebStream && currentMonitor.SecondPath
921+
);
922922
// When switching monitors, cookies may store a channel from the previous monitor that the current monitor does not have.
923+
streamChannel.value = streamChannelValue; // This will be easier than checking for a disabled option by going through the options. That is, we set the required option and if it is disabled, then we select the 'Primary' channel
924+
923925
if (streamChannel.options[streamChannel.selectedIndex].disabled) {
924926
streamChannelValue = 'Primary';
925927
}
928+
monitorStream.currentChannelStream = (streamChannelValue == 'Secondary') ? 1 : 0;
929+
streamChannel.value = streamChannelValue;
930+
}
931+
}
932+
933+
function manageStreamQualityVisibility() {
934+
const streamQuality = document.getElementById('streamQuality');
935+
const streamChannel = document.getElementById('streamChannel');
936+
const rateControl = document.getElementById('rateControl');
937+
938+
if (-1 === monitorStream.activePlayer.indexOf('zms')) {
926939
streamChannel.classList.remove("hidden-shift");
927940
streamQuality.classList.add("hidden-shift");
928-
streamChannel.value = streamChannelValue;
929941
rateControl.classList.add("hidden-shift");
930942
} else {
931943
streamQuality.classList.remove("hidden-shift");
@@ -1098,8 +1110,6 @@ function initPage() {
10981110
} else {
10991111
alert("No monitor found for id "+monitorId);
11001112
}
1101-
1102-
manageChannelStream();
11031113
} // initPage
11041114

11051115
function watchFullscreen() {
@@ -1319,8 +1329,9 @@ function changePlayer() {
13191329
streamCmdStop(true); // takes care of button state and calls stream.kill()
13201330
console.log('setting to ', $j('#player').val());
13211331
monitorStream.setPlayer($j('#player').val());
1322-
manageStreamQualityVisibility();
1332+
setChannelStream();
13231333
streamCmdPlay(true);
1334+
manageStreamQualityVisibility();
13241335
return;
13251336

13261337
setTimeout(function() {

0 commit comments

Comments
 (0)