Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ManagedMediaSource Support #5542

Merged
merged 1 commit into from
Aug 24, 2023
Merged

ManagedMediaSource Support #5542

merged 1 commit into from
Aug 24, 2023

Conversation

robwalch
Copy link
Collaborator

@robwalch robwalch commented Jun 5, 2023

This PR will...

  1. Use ManagedMediaSource (MMS) when available rather than MediaSource for MSE based playback
    • Adds preferManagedMediaSource config option which defaults to true. Set to false to use standard MediaSource when available even if MMS is present.
  2. Start and stop loading of media segments with MMS "startstreaming" and "endstreaming" events
    • Adds new new player API methods pauseBuffering() and resumeBuffering()
      (unlike startLoad() and stopLoad(), these methods do not interrupt Playlist loading)
  3. Cap max quality based on MMS quality:
    1. low = ABR selection limited to 1280x720p max
    2. medium = 1920x1080p max
    3. (other) = no limit
  4. Use HTMLSourceElements for MediaSource blob URL and set media.disableRemotePlayback to true to allow ManagedMediaSource to open (users can add additional source elements and allow remote playback as needed).
    • Setting preferManagedMediaSource to false prevents this behavior

Why is this Pull Request needed?

Using ManagedMediaSource when available allows the User Agent to manage buffer levels and limit quality based on information not available to the page.

Are there any points in the code the reviewer needs to double check?

ManagedMediaSource explainer: w3c/media-source#320

@@ -4,5 +4,9 @@

export function getMediaSource(): typeof MediaSource | undefined {
if (typeof self === 'undefined') return undefined;
return self.MediaSource || ((self as any).WebKitMediaSource as MediaSource);
return (
((self as any).ManagedMediaSource as typeof MediaSource) ||

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the API already available on Webkit ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is available on Safari 17 and iPadOS 17 beta

Comment on lines 180 to 183
// link video and media Source
try {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also test for WebKitPlaybackTargetAvailabilityEvent here before bothering to use source elements.

@JuanMorenoS
Copy link

JuanMorenoS commented Jun 22, 2023

Hi! TY so much for sharing this PR.
I'm testing that on iOS 17 (xcode emulator) and is not working.
I commented this line in order to force HLS.JS (maybe that logic is missing in the PR)

If you need help to finish this PR please let me know!

@robwalch
Copy link
Collaborator Author

robwalch commented Jun 22, 2023

Hi @JuanMorenoS,

ManagedMediaSource needs to be enabled via Settings > Safari > Advanced > Feature Flags > Managed Media Source API.

There is a known issue in iOS 17 beta 5 preventing the isTypeSupported check from passing. The library can not operate without passing isTypeSupported checks. Until there is a fix, you can test in Safari Technology Preview, or try iPad.

@adityapatadia
Copy link

More details available in this nice video: https://developer.apple.com/videos/play/wwdc2023/10122/

@robwalch robwalch force-pushed the feature/managed-media-source branch from 3e67c19 to 754951b Compare June 28, 2023 21:01
@robwalch robwalch force-pushed the feature/managed-media-source branch from 9a9ea70 to 6337b81 Compare July 5, 2023 22:47
@robwalch robwalch force-pushed the feature/managed-media-source branch from 6337b81 to 813d259 Compare August 23, 2023 19:19
@robwalch robwalch force-pushed the feature/managed-media-source branch from 813d259 to 432a62d Compare August 23, 2023 19:57
@robwalch robwalch merged commit 2e40955 into master Aug 24, 2023
15 of 16 checks passed
@robwalch robwalch deleted the feature/managed-media-source branch August 24, 2023 23:37
@JuanMorenoS
Copy link

Hi @robwalch ,

I was wondering if you've heard any updates about the issue in iOS 17? It's been released, but I'm still having trouble playing content with HLS.JS. Any help would be appreciated

@jyavenard
Copy link

jyavenard commented Sep 28, 2023

It will be available in iOS 17.1 beta 2

@matamatanot
Copy link
Contributor

🎉

https://webkit.org/blog/14735/webkit-features-in-safari-17-1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants