diff --git a/web/ajax/watch.php b/web/ajax/watch.php index d53ce6858..61b5c738e 100644 --- a/web/ajax/watch.php +++ b/web/ajax/watch.php @@ -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 diff --git a/web/includes/Event.php b/web/includes/Event.php index b5155c5cb..306df2ffd 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -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]; diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index fa39be27e..889628677 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -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);