4
4
5
5
const Ipfs = require ( '../../' )
6
6
const VideoStream = require ( 'videostream' )
7
+ const toStream = require ( 'it-to-stream' )
7
8
const {
8
9
dragDrop,
9
10
statusMessages,
@@ -18,14 +19,14 @@ document.addEventListener('DOMContentLoaded', async () => {
18
19
19
20
// Set up event listeners on the <video> element from index.html
20
21
const videoElement = createVideoElement ( )
21
- const hashInput = document . getElementById ( 'hash ' )
22
+ const cidInput = document . getElementById ( 'cid ' )
22
23
const goButton = document . getElementById ( 'gobutton' )
23
24
let stream
24
25
25
26
goButton . onclick = function ( event ) {
26
27
event . preventDefault ( )
27
28
28
- log ( `IPFS: Playing ${ hashInput . value . trim ( ) } ` )
29
+ log ( `IPFS: Playing ${ cidInput . value . trim ( ) } ` )
29
30
30
31
// Set up the video stream an attach it to our <video> element
31
32
const videoStream = new VideoStream ( {
@@ -46,10 +47,10 @@ document.addEventListener('DOMContentLoaded', async () => {
46
47
}
47
48
48
49
// This stream will contain the requested bytes
49
- stream = ipfs . catReadableStream ( hashInput . value . trim ( ) , {
50
+ stream = toStream . readable ( ipfs . cat ( cidInput . value . trim ( ) , {
50
51
offset : start ,
51
52
length : end && end - start
52
- } )
53
+ } ) )
53
54
54
55
// Log error messages
55
56
stream . on ( 'error' , ( error ) => log ( error ) )
@@ -73,6 +74,6 @@ document.addEventListener('DOMContentLoaded', async () => {
73
74
log ( 'IPFS: Drop an .mp4 file into this window to add a file' )
74
75
log ( 'IPFS: Then press the "Go!" button to start playing a video' )
75
76
76
- hashInput . disabled = false
77
+ cidInput . disabled = false
77
78
goButton . disabled = false
78
79
} )
0 commit comments