Skip to content

asynchronous request filters #610

Closed
Closed
@priyajeet

Description

@priyajeet

I am currently using v1 which allows request intercepting via source.setNetworkCallback(foo) and I believe the v2 equivalent for this is player.getNetworkingEngine().registerRequestFilter(foo)

In both cases I want to make a network request (or some async operation) inside foo, the result of which will be used in the actual filtering.

An example would be that I need to intercept all dash requests and decorate the headers with an authentication token. However this token may have expired half way during playback of the video. So I need to fetch a new token before allowing the next dash network request to happen. Essentially pausing it.

My current workaround is to increase the number of network retries for the dash player, and manage the token refresh outside the scope of the player network interceptor. This isolated token refresh request then alters some scope variable that function foo can eventually read. This works but is hacky and results in bunch of errors, say 401, but having a high retry count (and coupled with the new v2 backoffFactor) gets this going.

Another example would be that the dash player requests for a segment, however that response returns, say a 202, suggesting that the segment is still transcoding on the backend and not ready. One would like to prevent further requests till some async job suggests that the segment is ready and is OK to continue.

Can player.getNetworkingEngine().registerRequestFilter(foo) have foo that returns a promise which resolves to a modified shakaExtern.Requestupon which it should make the actual dash request.

Metadata

Metadata

Assignees

Labels

flag: good first issueThis might be a relatively easy issue; good for new contributorsstatus: archivedArchived and locked; will not be updatedtype: enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions