shaka-player icon indicating copy to clipboard operation
shaka-player copied to clipboard

Native HLS on Safari only for AirPlay

Open niklaskorz opened this issue 1 year ago • 7 comments

Have you read the FAQ and checked for duplicate open issues?

Yes

Is your feature request related to a problem? Please describe.

When using AirPlay on Safari with useNativeHlsOnSafari: false, AirPlay becomes unusable. This is because the blob source set on the video element cannot be handled by the AirPlay target.

Describe the solution you'd like

As of Safari 16.4, Safari can automatically fall back to another supported <source> element when starting AirPlay. An example is provided by this test in the WebKit repository. The basic idea would be to provide both the Media Source Extensions-backed video blob and the address of the HLS playlist as separate <source> elements as children of the <video> element.

Describe alternatives you've considered

An alternative would be to re-enable useNativeHlsOnSafari when AirPlay is requested by the user, seek to the previous timestamp and start playback again.

niklaskorz avatar Feb 23 '23 15:02 niklaskorz

@niklaskorz are you interested on send a PR for this?

avelad avatar Feb 28 '23 12:02 avelad

More info in https://developer.apple.com/wwdc23/10122

avelad avatar Jun 09 '23 11:06 avelad

I suppose I could work on #5271 and this in a combined PR @avelad, as the "new" AirPlay approach is explicitly mentioned in the context of Managed MSE. Interestingly the hls.js PR https://github.com/video-dev/hls.js/pull/5542 does not seem to have any AirPlay specific changes.

niklaskorz avatar Jun 09 '23 12:06 niklaskorz

After having merged https://github.com/shaka-project/shaka-player/pull/5683 this development has been unlocked.

avelad avatar Oct 11 '23 09:10 avelad

@niklaskorz are you interested on send a PR for this?

avelad avatar Jan 11 '24 14:01 avelad

More info in https://webkit.org/blog/15036/how-to-use-media-source-extensions-with-airplay/

avelad avatar Feb 29 '24 10:02 avelad

This snippet from the WebKit blog uses <source> tags to manage an alternate HLS source for AirPlay:

// Add MSE/MMS streaming source
const videoSource1 = document.createElement('source');
videoSource1.type = 'video/mp4';
videoSource1.src = URL.createObjectURL(source); // Create URL from MediaSource
video.appendChild(videoSource1);

// Add AirPlay-compatible HLS source
const videoSource2 = document.createElement('source');
videoSource2. type = 'application/x-mpegURL';
videoSource2.src = airplayURL;
video.appendChild(videoSource2);

We could do this, but we have to be careful to track those <source> elements and clean them up so the <video> element doesn't become cluttered over time after multiple playbacks.

joeyparrish avatar Feb 29 '24 19:02 joeyparrish