2121
2222 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/cloudinary-video-player/dist/cld-video-player.min.css">
2323 <script src="https://cdn.jsdelivr.net/npm/cloudinary-video-player/dist/cld-video-player.min.js"></script>
24-
25- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dashjs/2.9.3/dash.all.min.js"></script>
26- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-dash/2.11.0/videojs-dash.js"></script>
27-
2824 -->
2925
3026 < script type ="text/javascript " src ="./scripts.js "> </ script >
3127 < script src ="
https://cdn.jsdelivr.net/npm/[email protected] /src/ua-parser.min.js "
> </ script > 3228
3329 < script >
3430 window . addEventListener ( 'load' , function ( ) {
35- var cldConfig = { cloud_name : 'demo' , secure : true } ;
31+ var cldConfig = {
32+ cloud_name : 'demo' ,
33+ secure : true ,
34+ debug : true
35+ } ;
3636
3737 var uap = new UAParser ( navigator . userAgent ) ;
3838 playerHls = cloudinary . videoPlayer ( 'example-player-hls' , cldConfig ) ;
3939 playerHlsH265 = cloudinary . videoPlayer ( 'example-player-hls-h265' , cldConfig ) ;
4040 playerDash = cloudinary . videoPlayer ( 'example-player-dash' , cldConfig ) ;
4141 playerDashVp9 = cloudinary . videoPlayer ( 'example-player-dash-vp9' , cldConfig ) ;
42- playerHlsNoCodec = cloudinary . videoPlayer ( 'example-player-hls-no-codec' , cldConfig ) ;
43- playerDashNoCodec = cloudinary . videoPlayer ( 'example-player-dash-no-codec' , cldConfig ) ;
44- playerHlsIos = cloudinary . videoPlayer ( 'example-player-hls-ios' , Object . assign ( cldConfig , {
45- html5 : {
46- vhs : {
47- overrideNative : true
48- }
49- }
50- } ) ) ;
42+ playerFastStart = cloudinary . videoPlayer ( 'example-player-fast-start' , cldConfig ) ;
43+ playerHighQuality = cloudinary . videoPlayer ( 'example-player-high-quality' , cldConfig ) ;
5144
5245 playerHls . source (
5346 'sea_turtle' ,
5447 {
5548 sourceTypes : [ 'hls' ] ,
56- transformation : { streaming_profile : 'hd' } ,
57- info : { title : 'HLS' }
49+ info : { title : 'HLS /w sp_auto' }
5850 }
5951 ) ;
6052 playerHlsH265 . source (
8173 info : { title : 'MPEG-DASH vp9' }
8274 }
8375 ) ;
84- playerHlsNoCodec . source (
76+
77+ playerFastStart . source (
8578 'sea_turtle' ,
8679 {
8780 sourceTypes : [ 'hls' ] ,
88- info : { title : 'HLS' }
81+ info : { title : 'HLS /w fastStart' } ,
82+ adaptiveStreaming : {
83+ strategy : 'fastStart'
84+ }
8985 }
9086 ) ;
91- playerDashNoCodec . source (
87+
88+ playerHighQuality . source (
9289 'sea_turtle' ,
9390 {
94- sourceTypes : [ 'dash' ] ,
95- info : { title : 'MPEG-DASH' }
91+ sourceTypes : [ 'hls' ] ,
92+ info : { title : 'HLS /w fastStart' } ,
93+ adaptiveStreaming : {
94+ strategy : 'highQuality'
95+ }
9696 }
9797 ) ;
98- playerHlsIos . source (
99- 'sea_turtle' ,
100- {
101- sourceTypes : [ 'hls' ] ,
102- transformation : { streaming_profile : 'hd' } ,
103- info : { title : 'HLS' }
104- }
105- ) ;
10698
107- playerHls . on ( 'qualitychanged' , function ( data ) {
108- console . log ( 'HLS player' , data ) ;
109- } ) ;
110- playerHls . videojs . on ( 'playing' , function ( ) {
111- document . getElementById ( 'info-hls' ) . innerHTML = uap . getBrowser ( ) . name + ' is playing ' + playerHls . videojs . currentSrc ( ) ;
112- } ) ;
113- playerHls . on ( 'error' , function ( ) {
114- console . log ( playerHls . videojs . error ( ) ) ;
115- } )
116- playerHlsH265 . videojs . on ( 'playing' , function ( ) {
117- document . getElementById ( 'info-hls-h265' ) . innerHTML = uap . getBrowser ( ) . name + ' is playing ' + playerHlsH265 . videojs . currentSrc ( ) ;
118- } ) ;
119- playerDash . on ( 'qualitychanged' , function ( data ) {
120- console . log ( 'Dash player' , data ) ;
121- } ) ;
122- playerDash . videojs . on ( 'playing' , function ( ) {
123- document . getElementById ( 'info-dash' ) . innerHTML = uap . getBrowser ( ) . name + ' is playing ' + playerDash . videojs . currentSrc ( ) ;
124- } ) ;
125- playerDashVp9 . videojs . on ( 'playing' , function ( ) {
126- document . getElementById ( 'info-dash-vp9' ) . innerHTML = uap . getBrowser ( ) . name + ' is playing ' + playerDashVp9 . videojs . currentSrc ( ) ;
127- } ) ;
128- playerHlsNoCodec . videojs . on ( 'playing' , function ( ) {
129- document . getElementById ( 'info-hls-no-codec' ) . innerHTML = uap . getBrowser ( ) . name + ' is playing ' + playerHlsNoCodec . videojs . currentSrc ( ) ;
130- } ) ;
131- playerDashNoCodec . videojs . on ( 'playing' , function ( ) {
132- document . getElementById ( 'info-dash-no-codec' ) . innerHTML = uap . getBrowser ( ) . name + ' is playing ' + playerDashNoCodec . videojs . currentSrc ( ) ;
99+ [ playerHls , playerHlsH265 , playerDash , playerDashVp9 , playerFastStart , playerHighQuality ] . forEach ( player => {
100+ player . on ( 'qualitychanged' , function ( data ) {
101+ console . log ( player . options . videojsOptions . id + ' qualitychanged' , data ) ;
102+ } ) ;
103+ player . on ( 'playing' , function ( data ) {
104+ const info = player . videoElement . parentElement . parentElement . querySelector ( '.info' ) ;
105+ info . innerHTML = uap . getBrowser ( ) . name + ' is playing ' + player . videojs . currentSrc ( ) ;
106+ } ) ;
133107 } ) ;
134108 } , false ) ;
135109 </ script >
@@ -155,7 +129,7 @@ <h4>HLS 264</h4>
155129 width ="500 "
156130 class ="cld-video-player "
157131 > </ video >
158- < span id ="info-hls "> </ span >
132+ < p id ="info-hls " class =" info " > </ p >
159133 </ div >
160134
161135 < div class ="video-container mb-4 ">
@@ -167,7 +141,7 @@ <h4>HLS 265</h4>
167141 width ="500 "
168142 class ="cld-video-player ">
169143 </ video >
170- < span id ="info-hls-h265 "> </ span >
144+ < p id ="info-hls-h265 " class =" info " > </ p >
171145 </ div >
172146
173147 < div class ="video-container mb-4 ">
@@ -180,7 +154,7 @@ <h4>MPEG-DASH h264</h4>
180154 width ="500 "
181155 class ="cld-video-player ">
182156 </ video >
183- < span id ="info-dash "> </ span >
157+ < p id ="info-dash " class =" info " > </ p >
184158 </ div >
185159
186160 < div class ="video-container mb-4 ">
@@ -193,46 +167,33 @@ <h4>MPEG-DASH vp9</h4>
193167 width ="500 "
194168 class ="cld-video-player ">
195169 </ video >
196- < span id ="info-dash-vp9 "> </ span >
170+ < p id ="info-dash-vp9 " class =" info " > </ p >
197171 </ div >
198172
199173 < div class ="video-container mb-4 ">
200- < h4 > HLS no codec </ h4 >
174+ < h4 > HLS with fastStart </ h4 >
201175 < video
202- id ="example-player-hls-no-codec "
176+ id ="example-player-fast-start "
203177 playsinline
204178 controls
205179 muted
206180 width ="500 "
207181 class ="cld-video-player ">
208182 </ video >
209- < span id ="info-hls-no-codec " > </ span >
183+ < p id ="info-fast-start " class =" info " > </ p >
210184 </ div >
211185
212186 < div class ="video-container mb-4 ">
213- < h4 > DASH no codec </ h4 >
187+ < h4 > HLS with highQuality </ h4 >
214188 < video
215- id ="example-player-dash-no-codec "
189+ id ="example-player-high-quality "
216190 playsinline
217191 controls
218192 muted
219193 width ="500 "
220194 class ="cld-video-player ">
221195 </ video >
222- < span id ="info-dash-no-codec "> </ span >
223- </ div >
224-
225- < div class ="video-container mb-4 ">
226- < h4 > HLS 264 safari ios native override</ h4 >
227- < video
228- id ="example-player-hls-ios "
229- playsinline
230- controls
231- muted
232- width ="500 "
233- class ="cld-video-player ">
234- </ video >
235- < span id ="info-hls-ios "> </ span >
196+ < p id ="info-high-quality " class ="info "> </ p >
236197 </ div >
237198
238199 < p class ="mt-4 ">
@@ -270,7 +231,6 @@ <h3>Example Code:</h3>
270231 'sea_turtle',
271232 {
272233 sourceTypes: ['hls'],
273- transformation: {streaming_profile: 'hd'},
274234 info: {title: 'HLS'}
275235 }
276236 );
@@ -279,18 +239,9 @@ <h3>Example Code:</h3>
279239 'sea_turtle',
280240 {
281241 sourceTypes: ['dash'],
282- transformation: {streaming_profile: 'hd'},
283242 info: {title: 'MPEG-DASH'}
284243 }
285244 );
286-
287- playerHls.on('qualitychanged', (data) => {
288- console.log('HLS player', data);
289- });
290-
291- playerDash.on('qualitychanged', (data) => {
292- console.log('Dash player', data);
293- });
294245 </ code >
295246 </ pre >
296247 </ div >
0 commit comments