videojs / video.js

Video.js - open source HTML5 video player
https://videojs.com
Other
37.51k stars 7.4k forks source link

Play the HLS on the AWS Private Bucket #8456

Closed FahadRS closed 8 months ago

FahadRS commented 9 months ago

I am trying to play HLS on the AWS Private Bucket, where every resource needs to be signed with a presigned URL token. To play every chunk of the media, I need to load the token from the server and append it to every chunk request.

I know that in order to replace the token, I can use the following code:" player.tech().vhs.xhr.beforeRequest = function(options) { options.uri = options.uri + token; return options; };

The problem here is that I don't have the token on the client side; I have to request the token from the server. Is there any way I can make the beforeRequest wait until I load the token from the server?

mister-ben commented 8 months ago

beforeRequest and the hooks that replace that need to return the updated options so can't be asynchronous. You might need to fetch you token before setting the source.