This repository was archived by the owner on Jan 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +17
-12
lines changed
examples/browser-video-streaming Expand file tree Collapse file tree 5 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 18
18
cache : " yarn"
19
19
- name : Install dependencies
20
20
run : yarn install
21
+ - name : Install dependencies for browsers
22
+ run : npx playwright install-deps
21
23
- name : Run test:examples
22
24
run : yarn run test:examples
Original file line number Diff line number Diff line change 8
8
< title > IPFS with HLS-JS</ title >
9
9
< link rel ="icon " href ="favicon.ico " />
10
10
11
- < script
12
- defer
13
- src ="https://cdn.jsdelivr.net/npm/hlsjs-ipfs-loader@0.3.0/dist/index.js "
14
- > </ script >
15
- < script defer src ="https://cdn.jsdelivr.net/npm/hls.js@0.14.17 "> </ script >
16
-
17
11
< script type ="module " defer src ="./src/index.js "> </ script >
18
12
</ head >
19
13
< body >
20
14
< video id ="video " controls autoplay > </ video >
15
+ < div id ="status "> </ div >
21
16
</ body >
22
17
</ html >
Original file line number Diff line number Diff line change 10
10
"build" : " parcel build index.html --no-scope-hoist" ,
11
11
"serve" : " parcel serve index.html --open -p 8888" ,
12
12
"start" : " npm run serve" ,
13
- "test:example" : " npm run build && playwright test tests --browser=webkit --retries=3"
13
+ "test:example" : " npm run build && playwright test tests --browser=firefox --retries=3"
14
14
},
15
15
"browserslist" : " last 1 Chrome version" ,
16
16
"dependencies" : {
17
+ "hls.js" : " ^0.14.17" ,
18
+ "hlsjs-ipfs-loader" : " ^0.3.0" ,
17
19
"ipfs" : " ^0.58.0"
18
20
},
19
21
"devDependencies" : {
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
3
import Ipfs from 'ipfs'
4
+ import Hls from 'hls.js'
5
+ import HlsjsIpfsLoader from 'hlsjs-ipfs-loader'
4
6
5
- /* global Hls Ipfs HlsjsIpfsLoader */
6
- /* eslint-env browser */
7
7
document . addEventListener ( 'DOMContentLoaded' , async ( ) => {
8
8
const testHash = 'QmdpAidwAsBGptFB3b6A9Pyi5coEbgjHrL3K2Qrsutmj9K'
9
9
const repoPath = 'ipfs-' + Math . random ( )
@@ -13,11 +13,17 @@ document.addEventListener('DOMContentLoaded', async () => {
13
13
Hls . DefaultConfig . debug = false
14
14
if ( Hls . isSupported ( ) ) {
15
15
const video = document . getElementById ( 'video' )
16
+ const status = document . getElementById ( 'status' )
16
17
const hls = new Hls ( )
17
18
hls . config . ipfs = node
18
19
hls . config . ipfsHash = testHash
19
20
hls . loadSource ( 'master.m3u8' )
20
21
hls . attachMedia ( video )
21
- hls . on ( Hls . Events . MANIFEST_PARSED , ( ) => video . play ( ) )
22
+ hls . on ( Hls . Events . MANIFEST_PARSED , ( ) => {
23
+ const node = document . createTextNode ( "Video ready..." ) ;
24
+ status . appendChild ( node ) ;
25
+
26
+ video . play ( )
27
+ } )
22
28
}
23
29
} )
Original file line number Diff line number Diff line change @@ -12,13 +12,13 @@ const play = test.extend({
12
12
13
13
play . describe ( 'browser videostream:' , ( ) => {
14
14
// DOM
15
- const video = "#video "
15
+ const status = "#status "
16
16
17
17
play . beforeEach ( async ( { servers, page} ) => {
18
18
await page . goto ( `http://localhost:${ servers [ 0 ] . port } /` ) ;
19
19
} )
20
20
21
21
play ( 'should properly initialized a IPFS node and stream a video' , async ( { page } ) => {
22
- await page . waitForFunction ( ( el ) => document . querySelector ( el ) . readyState >= 2 , video ) ;
22
+ await page . waitForSelector ( ` ${ status } :has-text('Video ready')` )
23
23
} ) ;
24
24
} ) ;
You can’t perform that action at this time.
0 commit comments