mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-06-21 20:19:18 -04:00
- Correct HLS playback on the Watch page
- When executing Event->Length() , get the duration of the recorded event file if the duration in the database table is 0 - If native HLS playback fails in Safari, we first try playing MP4, and only if MP4 playback fails do we switch to MJPEG playback
This commit is contained in:
@@ -90,9 +90,9 @@ if ($rows) {
|
||||
$videoAttr = '';
|
||||
if ($event->DefaultVideo()) {
|
||||
$videoSrc = $event->getStreamSrc(array('mode'=>'mp4'), '&');
|
||||
$videoHlsSrc = $event->getStreamSrc(array('mode'=>'hls'), '&');
|
||||
$videoHlsSrc = $event->getStreamSrc(array('mode'=>'mp4hls'), '&');
|
||||
$videoDuration = htmlspecialchars((string)$event->Length());
|
||||
$videoAttr = ' video_src="' .$videoSrc. '" data-video-hls-src="' .$videoHlsSrc. '" data-video-duration="' .$videoDuration. '" data-event-start="'.htmlspecialchars($event->StartDateTime()).'"';
|
||||
$videoAttr = ' video_src="' .$videoSrc. '" data-video-hls-src="' .$videoHlsSrc. '" data-video-duration-secs="' .$videoDuration. '" data-event-start="'.htmlspecialchars($event->StartDateTime()).'"';
|
||||
}
|
||||
|
||||
// Modify the row data as needed
|
||||
|
||||
@@ -111,7 +111,7 @@ class Event extends ZM_Object {
|
||||
|
||||
public function Length(){
|
||||
$duration = 0;
|
||||
if(! isset($this->{'Length'})){
|
||||
if ( !isset($this->{'Length'}) || (float)$this->{'Length'} <= 0 ) {
|
||||
$files = glob($this->Path().'{/incomplete.*,/'.$this->{'Id'}.'-video.*}', GLOB_NOSORT | GLOB_BRACE);
|
||||
if (count($files) > 0) {
|
||||
$file = $files[0];
|
||||
|
||||
@@ -1776,9 +1776,16 @@ function playEventHLS(container, img, monitorId, fallbackToMjpeg, statusBar, eve
|
||||
video.addEventListener('error', function(e) {
|
||||
console.error(e);
|
||||
video.remove();
|
||||
fallbackToMjpeg();
|
||||
clearTimeout(video._fallbackTimer);
|
||||
tryPlayMp4(container, img, monitorId, fallbackToMjpeg, statusBar);
|
||||
});
|
||||
thumbnailVideoPlay(video, 'Native HLS', eventStart, statusBar);
|
||||
video._fallbackTimer = setTimeout(function() {
|
||||
if (video.readyState < 2) {
|
||||
video.remove();
|
||||
tryPlayMp4(container, img, monitorId, fallbackToMjpeg, statusBar);
|
||||
}
|
||||
}, 2000);
|
||||
} else {
|
||||
video.remove();
|
||||
tryPlayMp4(container, img, monitorId, fallbackToMjpeg, statusBar);
|
||||
|
||||
Reference in New Issue
Block a user