Playing M3U8 Files With HTML Video Tag

Playing HLS file from a server with a HTML video tag

Okay so I've found a solution to my problem using video.js + video.js http streaming.

  1. I needed to set my CORS rules on my Backblaze B2 Bucket, it's a setting on the screen with all your buckets to "Share everything in this bucket with all origins."

Next I just used this code segment using both video.js and the plugin for it for hls streaming for all major browsers with it which is video streaming https. Both of them just require a simple script tag from their respective cdns.

The documentation you need is found here: and here: and you need both as they perform different functions.
So the code that I found finally works in my case is:

<!DOCTYPE html>
<html lang="en" dir="ltr">
<meta charset="utf-8">
<title>My Video</title>
<link href="" rel="stylesheet" />
<!-- For IE8 (for Video.js versions prior to v7)
<script src=""></script>
<h1>My Video</h1>
<video-js id="my_video_1" class="vjs-default-skin" controls preload="auto" width="640" height="268">
<source src="" type="application/x-mpegURL">
<!--This is for Video.js by itself -->
<script src=""></script>
<!--This is for HLS compatibility with all major browsers-->
<script src = ""></script>
var player = videojs('my_video_1');

Playing m3u8 video with video tag

HLS is not supported on most browsers natively. But can be played via libraries such as hls.js.

html video tag not playing m3u8 file when serve by golang server

You have to set your header to the right type.
Try something like this:

func serveHandler(w http.ResponseWriter, r *http.Request){
w.Header().Set("Content-Type", "application/x-mpegURL")

tmpl := template.Must(template.ParseFiles("index.html"))
tmpl.Execute(w, "videosource/index.m3u8")


Related Topics

Leave a reply