Open benunternaehrer opened 12 months ago
v1.5 adds support for Managed Media Source (MMS) in Safari 17.1 and up. AirPlay is disabled by default to enable MMS over MSE. An AirPlay source alternative must be appended to your media element with the .m3u8 URL following the MediaSource blob:// source element (after calling Hls loadSource and attach). More information can be found here:
https://webkit.org/blog/14735/webkit-features-in-safari-17-1/
Not sure it's only related to Safari 17.1 as the problem also occurs on Safari 16.6 with tvOS 17.1. Either way, using the native HLS support in Safari instead of hls.js solves the problem for me. But would be good to have it working with hls.js. Adding a source to the video element seems to prioritize native HLS playback over hls.js.
When you load an item and attach a media element, a MediaSource source element is added (in Safari using the latest pre-release of hls.js):
hls.loadSource('https://yourdomain.com/video/main.m3u8');
hls.attachMedia(video);
result after calling loadSource and attachMedia:
<video playsinline>
<source type="video/mp4" src="blob://afe253ef-111e-4eaa-90ea-c8ebfa786510">
</video>
To enable AirPlay, after attaching media and loading, append an m3u8 source and re-enable remote playback:
const source = document.createElement('source');
source.src = url;
video.appendChild(source);
video.disableRemotePlayback = false;
final result with an alternative source:
<video playsinline>
<source type="video/mp4" src="blob://afe253ef-111e-4eaa-90ea-c8ebfa786510">
<source src="https://yourdomain.com/video/main.m3u8">
</video>
AirPlay requires an m3u8 URL for a remote device to load the media. MSE players use a “blob” URL, which connects the MediaSource to the DOM element used for playback but does not expose the m3u8 location needed for streaming remotely. Adding an alternative (fallback) source, as shown above, allows Safari 17 and up to use the correct path for remote playback.
The only way to AirPlay HLS in older versions of Safari is with native HLS playback.
What version of Hls.js are you using?
1.4.12
What browser (including version) are you using?
Safari 17.1.1
What OS (including version) are you using?
iPadOS 17.1.1
Test stream
https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8
Configuration
Additional player setup steps
<video id="video" controls x-webkit-airplay="allow" playsinline></video>
Checklist
Steps to reproduce
Expected behaviour
Video playback works via AirPlay with Audio and Video
(Same stream works for example with video.js)
What actually happened?
Only Audio is streamed to AirPlay device, Video continues to play on iPad.
Console output
Chrome media internals output
No response