Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does hls.js support data uri for playback? #6375

Open
samdubey opened this issue Apr 23, 2024 · 1 comment
Open

does hls.js support data uri for playback? #6375

samdubey opened this issue Apr 23, 2024 · 1 comment

Comments

@samdubey
Copy link

What do you want to do with Hls.js?

Use a Data URI: If you want to avoid serving the M3U8 file over a separate protocol, you can convert the M3U8 file to a data URI and embed it directly into your HTML file. This way, there won't be any mixed content issues since everything is within the same protocol.
Here's an example of how to convert an M3U8 file to a data URI and embed it in your HTML:

var m3u8Data = #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:10 #EXTINF:10.000, path_to_segment_1.ts #EXTINF:10.000, path_to_segment_2.ts #EXT-X-ENDLIST;

var videoPlayer = document.getElementById('videoPlayer');

// Set the data URI as the source for the video player
videoPlayer.src = 'data:application/x-mpegURL;base64,' + btoa(m3u8Data);

What have you tried so far?

No response

@samdubey samdubey added Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. Question labels Apr 23, 2024
@robwalch
Copy link
Collaborator

robwalch commented Apr 23, 2024

Yes, but not directly or officially (there are no tests or examples in test-streams). Try passing a data URI to hls.loadSource() (it works). Data URIs are handled in the loader via XHR (they are not parsed or decoded by HLS.js using atob). This is how EXT-X-KEY tag data URIs are handled.

path_to_segment_2.ts

Note that keys and segments in the encoded playlist must use absolute URLs in the asset - relative paths will not be resolved with a base data URI.

@robwalch robwalch added answered and removed Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants