forked from pgc-13/hlsjs-ipfs-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_usage.html
42 lines (38 loc) · 994 Bytes
/
basic_usage.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html>
<body>
<script src="https://unpkg.com/ipfs/dist/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="../dist/index.js"></script>
<script>
const repoPath = 'ipfs-' + Math.random()
const ipfs = new Ipfs({
init: false,
start: false,
repo: repoPath
})
ipfs.init(handleInit)
function handleInit (err) {
if (err) {
throw err
}
ipfs.start(() => {
var testhash = "QmdpAidwAsBGptFB3b6A9Pyi5coEbgjHrL3K2Qrsutmj9K"
Hls.DefaultConfig.loader = HlsjsIpfsLoader;
Hls.DefaultConfig.debug = false;
if(Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls();
hls.config.ipfs = ipfs;
hls.config.ipfsHash = testhash;
hls.loadSource('master.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
video.play();
});
}
});
}
</script>
<video id="video" controls></video>
</body>
</html>