fix: don't force HLS when user explicitly picked MP4 codec refs #4757

10a4f9af1 included $codec == 'MP4' in the HLS-eligibility check, which
broke native mp4 playback whenever an index.m3u8 was present — picking
MP4 from the dropdown silently went through HLS instead. MP4 means "play
the mp4 file directly"; honor that.

The MP4HLS / auto / DefaultVideo-ends-in-.m3u8 conditions still cover
closed events whose stored DefaultVideo predates the C++ fix that
preserves 'index.m3u8'.

Reported by @IgorA100 on commit 10a4f9af1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Isaac Connor
2026-05-16 11:47:42 -04:00
parent e378da3d1b
commit 375e82fd88

View File

@@ -354,12 +354,13 @@ if (file_exists($Event->Path().'/objdetect.jpg')) {
<div id="zoompan" class="zoompan">
<?php
if ($video_tag) {
// Prefer HLS byte-range playback whenever the manifest exists on disk and the
// user hasn't explicitly opted into a non-HLS playback mode. Closed events
// have DefaultVideo rewritten to the renamed mp4, so checking the file system
// is what catches them.
// Prefer HLS byte-range playback when the manifest exists on disk and the
// user picked MP4HLS / auto. Explicit MP4 means "play the mp4 file directly"
// and must stay non-HLS even when a manifest is available. Closed events
// recorded before DefaultVideo was preserved as 'index.m3u8' still need to
// fall through here on auto.
$has_hls = file_exists($Event->Path() . '/index.m3u8')
&& (($codec == 'MP4HLS') || ($codec == 'MP4') || ($codec == 'auto')
&& (($codec == 'MP4HLS') || ($codec == 'auto')
|| str_ends_with($Event->DefaultVideo(), '.m3u8'));
if ($has_hls) {
$Server = $Event->Server();