user2993497
user2993497

Reputation: 585

Preloading an m3u8 video in HTML with <link rel="preload">

I'm using the <link rel="preload"> attribute to preload my video for faster playback.

But my video is an .m3u8 file, which is a playlist file that links to several chunked .ts files.

In order to successfully preload my video, should I link to the playlist file

<link rel="preload" as="video" href="https://cdn.com/file.m3u8">

or

link to the source files like so:

<link rel="preload" as="video" href="https://cdn.com/file1.ts">
<link rel="preload" as="video" href="https://cdn.com/file2.ts">
<link rel="preload" as="video" href="https://cdn.com/file3.ts">

Upvotes: 0

Views: 1587

Answers (1)

Offbeatmammal
Offbeatmammal

Reputation: 8228

You should link to the m3u8 from a <video> tag, because you want the browser to determine at runtime what bandwidth the user can support to stream.

If your m3u8 is correctly formed and indicates that it's a VOD file (as opposed to a live stream) then some browsers will attempt to preload segments from a - better to use their logic in most cases.

Upvotes: 1

Related Questions