shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.1k stars 1.33k forks source link

Can't handle network requests over hls streaming in Safari #6932

Closed baturays closed 3 months ago

baturays commented 3 months ago

Have you read the Tutorials? Yes

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

If the question is related to FairPlay, have you read the tutorial?

Yes

What version of Shaka Player are you using? 4.3.3

What browser and OS are you using? Ventura - Safari (v16.3)

Please ask your question

Hello,

I have a system on my Safari browser that is protected with a DRM token and uses a CDN token for search parameters. When the CDN token expires, I regenerate it and intercept manifest requests, continuing with updated token parameters. In the playlists I play with Fairplay HLS, manifest requests are made every 6 seconds, and when the CDN token expires, I need to handle this by generating new token parameters and continuing.

However, on the DASH side, the register methods and the player's error events work correctly, but they do not work on the Fairplay HLS side. I cannot intercept manifest requests in any way, nor can I catch the 410 errors (server response due to CDN token expiration) from the network using the player's provided APIs.

I want to establish this logic on the HLS side as I have done with DASH Widevine. I would greatly appreciate your help.

Thank you.

avelad commented 3 months ago

Please, use streaming.useNativeHlsOnSafari = false (config option) Thanks!

baturays commented 3 months ago

Hello,

I have made the adjustments as you suggested, but there has been no change. I still cannot handle the requests sent over the network (manifest requests sent every 6 seconds), nor can I handle the 410 error thrown by the server when the CDN token expires. Events like onPlaying, onBuffering, and onRatechange are still working as they should.

baturays commented 3 months ago

Please, use streaming.useNativeHlsOnSafari = false (config option) Thanks!

Hello,

I have made the adjustments as you suggested, but there has been no change. I still cannot handle the requests sent over the network (manifest requests sent every 6 seconds), nor can I handle the 410 error thrown by the server when the CDN token expires. Events like onPlaying, onBuffering, and onRatechange are still working as they should.

avelad commented 3 months ago

I'm sorry, I was wrong, I didn't realize that you're using Fairplay ... try with streaming.useNativeHlsForFairPlay = false but... You have to read the tutorial carefully for FairPlay with MSE; not all providers may support it.

baturays commented 3 months ago

I'm sorry, I was wrong, I didn't realize that you're using Fairplay ... try with streaming.useNativeHlsForFairPlay = false but... You have to read the tutorial carefully for FairPlay with MSE; not all providers may support it.

Hello again, we are using Verimatrix, and our DRM integration is implemented as shown in the tutorials. However, the main thing I want to ask is this: The registerRequestFilter and registerResponseFilter methods we use over the Networking engine are not being handled in any way. This seems to be the main issue. Why are these methods, which are also used in the tutorials, not working at all for Fairplay?

avelad commented 3 months ago

When you use src= (not MSE), the native player is in charge of making the requests, not us. Verimatrix as far as I know does not support MSE, so the behavior you want to achieve is impossible (as far as I know).

baturays commented 3 months ago

When you use src= (not MSE), the native player is in charge of making the requests, not us. Verimatrix as far as I know does not support MSE, so the behavior you want to achieve is impossible (as far as I know).

Hi,

I am not using the src= attribute; instead, I am setting the video element through MSE.

The process of loading the video is as follows:

I get the video element and initialize Shaka Player with this element. Then, I call the Player.load method with a specific URL to load the video. I found the following code in your documentation regarding Verimatrix FairPlay support and implemented it:

javascript Copy code shaka.polyfill.PatchedMediaKeysApple.install(); const FairPlayUtils = shaka.util.FairPlayUtils; player.getNetworkingEngine() .registerRequestFilter(FairPlayUtils.verimatrixFairPlayRequest); player.getNetworkingEngine() .registerResponseFilter(FairPlayUtils.commonFairPlayResponse); player.configure('drm.initDataTransform', FairPlayUtils.verimatrixInitDataTransform); However, when I implement this code, the registerRequestFilter and registerResponseFilter methods are never invoked. This indicates that Shaka Player is not intercepting and handling the requests.

Do you have any other suggestions or solutions regarding Verimatrix and MSE support? Is there any additional configuration or setting on the browser side that I need to apply?

Thanks.

avelad commented 3 months ago

According to your code you should be using src= :) Please check the documentation: https://shaka-player-demo.appspot.com/docs/api/tutorial-fairplay.html Captura de pantalla 2024-07-01 a las 14 37 00

baturays commented 3 months ago

Hello,

I set the src= method as suggested, but unfortunately, I didn't notice any change in behavior. My content is in the .ts format. I'm still facing issues with playing FairPlay HLS content using Shaka Player. I'm wondering if there's something crucial that I might be missing in my implementation specific to HLS playlists in the .ts format.

Could you please provide any additional insights or steps that could help me troubleshoot this further?

Thank you.

avelad commented 3 months ago

It is not possible to do what you want with Shaka Player with what you comment, sorry!

baturays commented 3 months ago

My goal is to ensure that the registerRequestFilter and registerResponseFilter methods work as expected with FairPlay content in Shaka Player. I need to handle network events effectively for my implementation. As you suggested , i switched to use src= , nothing changed.

caridley commented 2 months ago

You might be able to accomplish this with a service worker.