Skip to content

Commit b11464e

Browse files
authored
Merge pull request #3 from JantsoP/main
Add possbile fix for iOS streaming [EXPERIMENTAL + UNTESTED]
2 parents d9976f8 + 4c448c6 commit b11464e

2 files changed

Lines changed: 63 additions & 2 deletions

File tree

resources/js/Components/Livestream/VideoJsPlayer.vue

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ import videojs from 'video.js';
1414
import 'video.js/dist/video-js.css';
1515
import 'videojs-hotkeys';
1616
17+
18+
/* --- ADD: Native HLS detection for Apple browsers (minimal, additive) --- */
19+
const __isIOSLike__ =
20+
/iP(hone|od|ad)/.test(navigator.platform) ||
21+
/iPad|iPhone|iPod/.test(navigator.userAgent) ||
22+
(/Macintosh/.test(navigator.userAgent) && 'ontouchend' in document);
23+
24+
const __isSafari__ = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
25+
const __useNativeHls__ = __isIOSLike__ || __isSafari__;
26+
/* --- END ADD --- */
27+
1728
// Make videojs available globally for plugins that require it
1829
window.videojs = videojs;
1930
@@ -255,7 +266,26 @@ const initializePlayer = async () => {
255266
}
256267
257268
// Create player instance
258-
player = videojs(videoPlayer.value, options);
269+
270+
// --- ADD: Prioritize native HLS on iOS/Safari without changing original options ---
271+
try {
272+
if (typeof __useNativeHls__ !== 'undefined' && __useNativeHls__) {
273+
if (typeof options !== 'undefined' && options) {
274+
options.techOrder = ['html5'];
275+
if (options.html5 && options.html5.vhs) {
276+
options.html5.vhs.overrideNative = false;
277+
} else {
278+
options.html5 = options.html5 || {};
279+
options.html5.vhs = options.html5.vhs || {};
280+
options.html5.vhs.overrideNative = false;
281+
}
282+
}
283+
}
284+
} catch (e) {
285+
// no-op
286+
}
287+
// --- END ADD ---
288+
player = videojs(videoPlayer.value, options);
259289
260290
// Firefox-specific error handling
261291
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');

resources/js/Pages/RecordingPlayer.vue

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ import 'video.js/dist/video-js.css';
8989
import 'videojs-contrib-quality-levels';
9090
import '@silvermine/videojs-chromecast/dist/silvermine-videojs-chromecast.css';
9191
92+
93+
/* --- ADD: Native HLS detection for Apple browsers (minimal, additive) --- */
94+
const __isIOSLike__ =
95+
/iP(hone|od|ad)/.test(navigator.platform) ||
96+
/iPad|iPhone|iPod/.test(navigator.userAgent) ||
97+
(/Macintosh/.test(navigator.userAgent) && 'ontouchend' in document);
98+
99+
const __isSafari__ = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
100+
const __useNativeHls__ = __isIOSLike__ || __isSafari__;
101+
/* --- END ADD --- */
102+
103+
92104
// Make videojs available globally for plugins
93105
window.videojs = videojs;
94106
@@ -491,7 +503,26 @@ const initializePlayer = async () => {
491503
};
492504
493505
// Initialize Video.js player
494-
player = videojs(videoPlayer.value, options, function() {
506+
507+
// --- ADD: Prefer native HLS on iOS/Safari without changing original options ---
508+
try {
509+
if (typeof __useNativeHls__ !== 'undefined' && __useNativeHls__) {
510+
if (typeof options !== 'undefined' && options) {
511+
options.techOrder = ['html5'];
512+
if (options.html5 && options.html5.vhs) {
513+
options.html5.vhs.overrideNative = false;
514+
} else {
515+
options.html5 = options.html5 || {};
516+
options.html5.vhs = options.html5.vhs || {};
517+
options.html5.vhs.overrideNative = false;
518+
}
519+
}
520+
}
521+
} catch (e) {
522+
// no-op
523+
}
524+
// --- END ADD ---
525+
player = videojs(videoPlayer.value, options, function() {
495526
// Player is ready
496527
console.log('Video.js player ready');
497528

0 commit comments

Comments
 (0)