mirror of https://github.com/jlelse/GoBlog
8 changed files with 62 additions and 1 deletions
@ -0,0 +1,12 @@
|
||||
package main |
||||
|
||||
import "embed" |
||||
|
||||
const videoPlaylistParam = "videoplaylist" |
||||
|
||||
//go:embed hlsjs/*
|
||||
var hlsjsFiles embed.FS |
||||
|
||||
func (p *post) hasVideoPlaylist() bool { |
||||
return p.firstParameter(videoPlaylistParam) != "" |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,32 @@
|
||||
(function () { |
||||
function loadVideo() { |
||||
// Get video div element
|
||||
let videoDivEl = document.getElementById('video') |
||||
|
||||
// External Video URL
|
||||
let videoUrl = videoDivEl.dataset.url |
||||
|
||||
// Create video element
|
||||
let videoEl = document.createElement('video') |
||||
videoEl.controls = true |
||||
videoEl.classList.add('fw') |
||||
|
||||
// Load video
|
||||
if (Hls.isSupported()) { |
||||
let hls = new Hls() |
||||
hls.loadSource(videoUrl) |
||||
hls.attachMedia(videoEl) |
||||
} else if (videoEl.canPlayType('application/vnd.apple.mpegurl')) { |
||||
videoEl.src = videoUrl |
||||
} |
||||
|
||||
// Add video element
|
||||
videoDivEl.appendChild(videoEl) |
||||
} |
||||
|
||||
// JS
|
||||
let script = document.createElement('script') |
||||
script.src = '/-/hlsjs/hls.js?v=1.1.5' |
||||
script.onload = loadVideo |
||||
document.head.appendChild(script) |
||||
})() |
Loading…
Reference in new issue