Appearance
VideoJS (dash playback)
html
<video id="vid-1" class="video-js vjs-default-skin"></video>js
let player = videojs('vid-1', {
controls: true,
muted: true,
autoplay: true,
preload: "auto",
fluid: true,
html5: {
vhs: {
overrideNative: true,
},
nativeVideoTracks: false,
nativeAudioTracks: false,
nativeTextTracks: false,
},
dash: {
streaming: {
abr: {
ABRStrategy: "abrL2A",
maxBitrate: {
audio: -1,
video: -1,
},
minBitrate: {
audio: -1,
video: -1,
},
initialBitrate: {
audio: -1,
video: 3000,
},
autoSwitchBitrate: {
audio: true,
video: true,
},
fetchThroughputCalculationMode: "abrFetchThroughputCalculationAAST"
},
}
}
});
...
// DASH
player.src({
src: "<STREAM URL HERE>",
type: "application/dash+xml"
});
...
// HLS
player.src({
src: "<STREAM URL HERE>",
type: "application/x-mpegURL",
});
...
// This is an example of, once loaded, seek to live immediately.
player.on("playing", function () {
if (/safari/i.test(navigator.userAgent)) {
const seekable = player.seekable();
if (seekable.length > 0 && player.currentTime() < 10) {
setTimeout(() => {
player.currentTime(seekable.end(0) - 3);
}, 1000);
}
}
});