This repository was archived by the owner on Jan 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +18
-6
lines changed
examples/browser-video-streaming Expand file tree Collapse file tree 4 files changed +18
-6
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 9
9
< link rel ="icon " href ="favicon.ico " />
10
10
11
11
< script
12
- defer
12
+ crossorigin
13
13
src ="https://cdn.jsdelivr.net/npm/hlsjs-ipfs-loader@0.3.0/dist/index.js "
14
14
> </ script >
15
- < script defer src ="https://cdn.jsdelivr.net/npm/hls.js@0.14.17 "> </ script >
15
+ < script
16
+ crossorigin
17
+ src ="https://cdn.jsdelivr.net/npm/hls.js@0.14.17 "
18
+ > </ script >
16
19
17
20
< script type ="module " defer src ="./src/index.js "> </ script >
18
21
</ head >
19
22
< body >
20
23
< video id ="video " controls autoplay > </ video >
24
+ < div id ="status "> </ div >
21
25
</ body >
22
26
</ html >
Original file line number Diff line number Diff line change 2
2
3
3
import Ipfs from 'ipfs'
4
4
5
- /* global Hls Ipfs HlsjsIpfsLoader */
5
+ /* global Hls HlsjsIpfsLoader */
6
6
/* eslint-env browser */
7
7
document . addEventListener ( 'DOMContentLoaded' , async ( ) => {
8
8
const testHash = 'QmdpAidwAsBGptFB3b6A9Pyi5coEbgjHrL3K2Qrsutmj9K'
@@ -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