Comments (8)
The application level redirects tutorial covers both the making of new requests and overwriting the response data, so the code snippet there is probably a good starting point for you: https://shaka-player-demo.appspot.com/docs/api/tutorial-application-level-redirects.html
from shaka-player.
Roughly, yes. But you will have to overwrite the fields of res
in your snippet, rather than return a different object.
You want some of the details from this tutorial (overwriting part of the response):
https://shaka-player-demo.appspot.com/docs/api/tutorial-license-wrapping.html
And some of the details from this tutorial (sending a new async request from a filter):
https://shaka-player-demo.appspot.com/docs/api/tutorial-license-server-auth.html
This could probably use a new tutorial entry if we don't add an explicit API of some kind.
from shaka-player.
You can use something like:
player.getNetworkingEngine().registerRequestFilter(function(type, request, context) {
// Only manipulate license responses for example
if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
// Do something
}
});
As such there is no retry event.
from shaka-player.
Thanks @avelad for the response.
Not sure if that'll do in my case, however. I am sending a Bearer <token>
with the Authorization
header. The server will respond with HTTP 401 and a code auth/token-expired
- only then I know that the request failed and that I have to refresh the token.
from shaka-player.
You can register a response filter to intercept the HTTP 401. If you make the filter async, it can refresh the token, then replicate the original request with the new token, and finally insert the new response in place of the first one.
from shaka-player.
This seems common enough, so if you want to propose an API to simplify this process for users, I'd be happy to review it.
from shaka-player.
@joeyparrish thank you! :)
If I get that right then I should be able to do somethign like this:
player.getNetworkingEngine()?.registerResponseFilter(async (req, res) => {
if (res.status === 401) {
const error = JSON.parse(String(res.data)) as HTTPError;
if (error.code === 'auth/token-expired') {
// 1. Refresh token
// 2. fetch(res.uri)
// 3. return new response object
}
}
return res;
});
from shaka-player.
Thanks a lot guys! With that I should be able to fix the issue! :)
from shaka-player.
Related Issues (20)
- Error with clearkey config on live streams HOT 22
- The timelineregionenter event is not being fired in certain scenarios
- Add segment URL to segment-related error codes
- Failure to find the segment lookupTime will result in infinite buffering. HOT 1
- UI not updates/refreshes after loading a new file. HOT 2
- How can I query for the active codec and bandwidth being played in a mixed-codec, multi-period manifest? HOT 2
- Combining MPD files shaving milliseconds from the videos
- Issue Playing MPEG-4 part 2 Video with MP3 Audio Using Shaka Player HOT 2
- CatchUp playback stuck after first frame rendered always on Samsung Tizen 5.0, 7.0 TV.
- changing textdisplayfactory creates bogus subtitle track with native webm video. HOT 2
- Getting thumbnails and using it with HLS HOT 4
- Doesn't play intermittently in Safari. HOT 3
- Use CastProxy method .cast() to play a new Manifest and not the one already playing locally HOT 2
- Add shaka namespace types to generated externs
- Shaka player with Playready DRM report FAILED_TO_GENERATE_LICENSE_REQUEST error.(EDGE Broswer)
- AudioContext gets incorrect values upon switching tracks with different channels count. HOT 2
- Shaka player continues to play a few seconds after reaching playRangeEnd
- Provide hard coded manifest to shaka
- Crash on Comcast X1 devices from v4.7+ with a certain stream HOT 1
- Multi Period Drm in DASH
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shaka-player.