Novage / p2p-media-loader

An open-source engine for P2P streaming of live and on demand video directly in a web browser HTML page
https://novage.com.ua/p2p-media-loader/demo.html
Apache License 2.0
1.43k stars 315 forks source link

Is it possible to detect supported browser or switch to turn off p2p when error #412

Closed stevenking888 closed 1 month ago

stevenking888 commented 1 month ago

I found an problem with some Safari browser on some Apple device. (The most case error in hls.js debug log is can't decode but when I'm not use P2P no problem with the same playlis) So I think is it possible to add 'isSupported' method and on error event listener to switch to normal HLS without P2P.

I try to add 'isP2PDisabled: true' when error happended but seem to not solve.

Can we share some idea for handle this situation ?

mrlika commented 1 month ago

There is isSupported method in Hls.js that should do the checks.

DimaDemchenko commented 1 month ago

@stevenking888 In case Hls.isSupported() doesn't solve your problem, please provide the following details:

dsyscms commented 1 month ago

I found an problem with some Safari browser on some Apple device. (The most case error in hls.js debug log is can't decode but when I'm not use P2P no problem with the same playlis) So I think is it possible to add 'isSupported' method and on error event listener to switch to normal HLS without P2P.

I try to add 'isP2PDisabled: true' when error happended but seem to not solve.

Can we share some idea for handle this situation ?

I use mac xcode Simulator test,even if ios version > 17.1.1,can not use ManagedMediaSource api play video,but use Real machine debugger can play video,so i use js check it.

hls.js Hls.isSupported() Inaccurate judgment dash.js dashjs.supportsMediaSource() Inaccurate judgment shaka.Player.isBrowserSupported() Inaccurate judgment

Accurate judgment:


                  if (shaka.Player.isBrowserSupported()) {
                      let supportFlag = false;
                      const mediaType = 'video/mp4; codecs="mp4a.40.2,avc1.4d4015"';
                      if ("ManagedMediaSource" in window && ManagedMediaSource.isTypeSupported(mediaType)) supportFlag = true;
                      if ("MediaSource" in window && MediaSource.isTypeSupported(mediaType)) supportFlag = true;

                      if (!supportFlag) {
                          video.src = url;
                          return;
                      }
                      const player = new shaka.Player();
                      player.configure({
                          streaming: {
                              // bufferingGoal: 120
                          }
                      });

                      await player.attach(video);
                      // Try to load a manifest.
                      // This is an asynchronous process.
                      try {
                          await player.load(url);
                      } catch (e) {
                          // onError is executed if the asynchronous load fails.
                          console.log(e);

                      }

                  } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
                      video.src = url;
                  }

test

mrlika commented 1 month ago

There is a bug in the iPhone simulator. It doesn't support required MMS (it is how MSE is called on iOS) feature/codecs for Hls.js to run. Do test/development on iPad simulator or real iOS device.

mrlika commented 1 month ago

Xcode was recently updated, and we will test if the issue with MMS in the iPhone simulator is fixed there.

mrlika commented 1 month ago

MMS is fixed and works in iOS 18 simulators:

image image
stevenking888 commented 1 month ago

I found problem only on Mac Safari. When play a while (not over 5 minute) double tested with multiple Mac devices

Mac pass these condtions

window.MediaSource !== 'undefined' window.WebKitMediaSource !== 'undefined'; RTCPeerConnection !== 'undefined' webkitRTCPeerConnection !== 'undefined' mozRTCPeerConnection !== 'undefined'

Screenshot 2024-09-22 072258
mrlika commented 1 month ago

We can't reproduce the issue with Safari. All the videos play for us for over 5 minutes on Safari. Is the problem reproducible with our demo?