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

Add Support for Managed Media Source Extensions in MediaElement.js to Enhance Compatibility with iOS 17.1+ #2959

Open
DimaDemchenko opened this issue May 7, 2024 · 0 comments

Comments

@DimaDemchenko
Copy link

Issue:
When attempting to play HLS streams on iOS devices using hls renderer in MediaElement.js, the player fails and displays an error. This issue is critical as it affects user experience on iOS devices.

Description:
We are developing a project that leverages P2P video delivery integrated with MediaElement.js and Hls.js. Our goal is to ensure broad compatibility across devices, including iPhones. However, the current implementation encounters compatibility issues on iOS, primarily due to the lack of Managed Media Source Extensions support.

Player configuration:

const player = new MediaElementPlayer(videoElement.id, {
    renderers: ["native_hls"],
    // additional configuration...
});

Proposed Solution:
After I got the error I tried to modify build file.

var HlsNativeRenderer = {
    name: 'native_hls',
    options: {
        prefix: 'native_hls',
        hls: {
            path: 'https://cdn.jsdelivr.net/npm/hls.js@latest',
            autoStartLoad: false,
            debug: false
        }
    },

    canPlayType: function canPlayType(type) {

         // here I added a check for MMS
        return (_constants.HAS_MSE || ("ManagedMediaSource" in window)) && 
               ['application/x-mpegurl', 'application/vnd.apple.mpegurl', 'audio/mpegurl', 'audio/hls', 'video/hls'].indexOf(type.toLowerCase()) > -1;
    },
};

After implementing the above modification in build file, the player successfully played HLS content on an iPhone using hls renderer, resolving the compatibility issue.

Screenshots:

  • Error before build file modification
    image
  • Successful playback after modification
    image
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

No branches or pull requests

1 participant