Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion resources/js/Components/Livestream/VideoJsPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ import videojs from 'video.js';
import 'video.js/dist/video-js.css';
import 'videojs-hotkeys';


/* --- ADD: Native HLS detection for Apple browsers (minimal, additive) --- */
const __isIOSLike__ =
/iP(hone|od|ad)/.test(navigator.platform) ||
/iPad|iPhone|iPod/.test(navigator.userAgent) ||
(/Macintosh/.test(navigator.userAgent) && 'ontouchend' in document);

const __isSafari__ = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
const __useNativeHls__ = __isIOSLike__ || __isSafari__;
/* --- END ADD --- */

// Make videojs available globally for plugins that require it
window.videojs = videojs;

Expand Down Expand Up @@ -255,7 +266,26 @@ const initializePlayer = async () => {
}

// Create player instance
player = videojs(videoPlayer.value, options);

// --- ADD: Prioritize native HLS on iOS/Safari without changing original options ---
try {
if (typeof __useNativeHls__ !== 'undefined' && __useNativeHls__) {
if (typeof options !== 'undefined' && options) {
options.techOrder = ['html5'];
if (options.html5 && options.html5.vhs) {
options.html5.vhs.overrideNative = false;
} else {
options.html5 = options.html5 || {};
options.html5.vhs = options.html5.vhs || {};
options.html5.vhs.overrideNative = false;
}
}
}
} catch (e) {
// no-op
}
// --- END ADD ---
player = videojs(videoPlayer.value, options);

// Firefox-specific error handling
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
Expand Down
33 changes: 32 additions & 1 deletion resources/js/Pages/RecordingPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ import 'video.js/dist/video-js.css';
import 'videojs-contrib-quality-levels';
import '@silvermine/videojs-chromecast/dist/silvermine-videojs-chromecast.css';


/* --- ADD: Native HLS detection for Apple browsers (minimal, additive) --- */
const __isIOSLike__ =
/iP(hone|od|ad)/.test(navigator.platform) ||
/iPad|iPhone|iPod/.test(navigator.userAgent) ||
(/Macintosh/.test(navigator.userAgent) && 'ontouchend' in document);

const __isSafari__ = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
const __useNativeHls__ = __isIOSLike__ || __isSafari__;
/* --- END ADD --- */


// Make videojs available globally for plugins
window.videojs = videojs;

Expand Down Expand Up @@ -491,7 +503,26 @@ const initializePlayer = async () => {
};

// Initialize Video.js player
player = videojs(videoPlayer.value, options, function() {

// --- ADD: Prefer native HLS on iOS/Safari without changing original options ---
try {
if (typeof __useNativeHls__ !== 'undefined' && __useNativeHls__) {
if (typeof options !== 'undefined' && options) {
options.techOrder = ['html5'];
if (options.html5 && options.html5.vhs) {
options.html5.vhs.overrideNative = false;
} else {
options.html5 = options.html5 || {};
options.html5.vhs = options.html5.vhs || {};
options.html5.vhs.overrideNative = false;
}
}
}
} catch (e) {
// no-op
}
// --- END ADD ---
player = videojs(videoPlayer.value, options, function() {
// Player is ready
console.log('Video.js player ready');

Expand Down
Loading