Skip to content

Instantly share code, notes, and snippets.

@thebells1111
Last active June 10, 2021 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebells1111/9ac48fd822d009cf7fa498c0e262b5da to your computer and use it in GitHub Desktop.
Save thebells1111/9ac48fd822d009cf7fa498c0e262b5da to your computer and use it in GitHub Desktop.
Minimum implementation of videojs, p2p and hls
<head>
<link href="https://vjs.zencdn.net/7.11.4/video-js.css" rel="stylesheet" />
<script
src="https://cdn.jsdelivr.net/npm/p2p-media-loader-core@latest/build/p2p-media-loader-core.min.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@latest/build/p2p-media-loader-hlsjs.min.js"></script>
<script src="https://vjs.zencdn.net/7.11.4/video.min.js"></script>
<script
src=" https://cdn.streamroot.io/videojs-hlsjs-plugin/1/stable/videojs-hlsjs-plugin.js"></script>
</head>
<body>
<video id="video_1" class="video-js" controls preload="auto">
<source
src="https://noagendatube.com/static/streaming-playlists/hls/7f80cf89-ac4e-4869-95b8-bcf8f7ca23b7/master.m3u8"
type="application/x-mpegURL" />
</video>
<script>
function p2pSetup() {
if (p2pml.hlsjs.Engine.isSupported()) {
const engine = new p2pml.hlsjs.Engine();
const options = {
html5: {
hlsjsConfig: {
capLevelToPlayerSize: true,
liveSyncDurationCount: 5,
loader: engine.createLoaderClass(),
},
},
};
const player = videojs('video_1', options);
p2pml.hlsjs.initVideoJsHlsJsPlugin(player);
}
}
p2pSetup()
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment