More accurate next player selection and preventing endless restarts when a specific player is selected - #4960
More accurate next player selection and preventing endless restarts when a specific player is selected#4960IgorA100 wants to merge 20 commits into
Conversation
…mple, H265), select the next player (MonitorStream.js)
…b in HLS mode, stop playback and restart. Yes, for now, it will restart in an infinite loop if a specific player is selected in the browser. However, this will be changed in the next PR ZoneMinder#4960. - Execute this.updateStreamInfo('', '') only after playback starts, not after MEDIA_ATTACHED, since that will cause a delay. There may be more errors later (for example, an unsupported audio codec, an m3u8 manifest error, or other errors.) - Execute this.updateStreamInfo('', 'Error') and log errors only if the error is fatal. - Moved this.streamErrorRegistration() lower in the code.
…re comprehensive error handling. - Added getCountStreamErrors() and resetCountStreamErrors() methods. - On the Montage page, run hls.js without parsing RTSP2WebType == "HLS" because we use automatic player switching, and even if we don't use the HLS type by default, the player may switch to HLS when using RTSP2Web. - Added waitingWebrtcPlayback to video-stream.js to detect the start of RTC playback. If we receive a 'webrtc/candidate' candidate, the next step is to start playback. We wait 3 seconds, and if the video hasn't loaded, we log the error and switch to another player. - Error logging in video-stream.js occurs via errorHandling() and allows us to display a text message in the video display block. - Before logging errors, we change monitorStream.player to a specific go2rtc_webrtc or go2rtc_mse player, since we don't have just "go2rtc" in the list of players to switch to. - We'll simplify getting monitorStream: instead of looking for the parent liveStream and getting its ID, we'll directly request getMonitorStream(stringToNumber(this.id)) - Go2RTC errors now generate the onErrorGo2RTC event. - Added the ability to display text information (typically used to inform about errors) in the block where the stream is displayed. The class for the block is ".info-text" - We no longer need the changes made in ZoneMinder@8b9546d - this.started = false; In this.stop() in MonitorStream.js we will move it higher in the code so that when stopping, the correct state of the stream is already set.
…into patch-865636
|
@connortechnology |
…(an annoying typo when copying/pasting)
…rs is reached when restarting the stream.
…tch page. - Some players may take a long time to start playing a stream (several seconds) and if a short cycle is selected (5 or 10 seconds), then half of the time or more the stream is in standby mode and viewing may occur within 1-5 seconds instead of the planned 5 or 10 seconds. Now the player will play the stream for the time specified in the cycle parameters - If a specific player is selected on the page, then in case of repeated errors it will switch to the next monitor. In the "Auto" mode, theoretically we should always get to the ZMS player. - This change will only work if approved by PR ZoneMinder#4960
|
Isaac, is there anything I should redo or do you not have time to check this PR? |
There was a problem hiding this comment.
Pull request overview
This PR improves stream playback robustness in the classic web UI by enhancing automatic player switching and adding safeguards to prevent endless restart loops when a specific player is selected (especially around Go2RTC/RTSP2Web edge cases like unsupported codecs).
Changes:
- Adds consecutive playback-error counting with a stop-after-N-attempts behavior and reset hooks on successful playback.
- Improves player switching logic (Auto vs pinned selections) and expands error handling/reporting (including UI text overlays).
- Adjusts Montage behavior to allow automatic switching to HLS when RTSP2Web is enabled (and adds WebRTC “start detection” timeout handling).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| web/skins/classic/views/montage.php | Load HLS support whenever RTSP2Web is enabled to support auto-switching scenarios. |
| web/skins/classic/js/skin.js | Adds Go2RTC error event handling/fallback and improves track-based logic for switching players when video is missing. |
| web/skins/classic/css/base/skin.css | Adds .info-text styling for in-stream informational/error text overlays. |
| web/js/video-stream.js | Enhances Go2RTC event/error handling and integrates error counting reset + WebRTC startup timeout logic. |
| web/js/MonitorStream.js | Introduces error-count limiting, player selection tweaks, info-text support, and updated RTSP2Web MSE error handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I'll come back to this PR a bit later, as I'm currently busy fixing the KeyframeOnly decoding mode. |
…ear the go2rtc.events.error listener.
…s" with "monitorStream"
|
I made the necessary adjustments and left comments. |
this.started = false; In this.stop() in MonitorStream.js we will move it higher in the code so that when stopping, the correct state of the stream is already set.No, we'll leave everything as is in this PR, otherwise some things will break. However, in the future, we'll need to analyze the move of this.started = false; further up in the code in more detail.