@@ -9,6 +9,10 @@ import {getAbsoluteURL} from '../../src/js/utils/url.js';
9
9
const Html5 = videojs . getTech ( 'Html5' ) ;
10
10
const wait = 1 ;
11
11
let qunitFn = 'module' ;
12
+ const blobSrc = {
13
+ src : 'blob:something' ,
14
+ type : 'video/mp4'
15
+ } ;
12
16
const testSrc = {
13
17
src : 'http://vjs.zencdn.net/v/oceans.mp4' ,
14
18
type : 'video/mp4'
@@ -132,6 +136,20 @@ QUnit[qunitFn]('sourceset', function(hooks) {
132
136
} ) ;
133
137
} ) ;
134
138
139
+ QUnit . test ( 'data-setup one blob' , function ( assert ) {
140
+ const done = assert . async ( ) ;
141
+
142
+ this . mediaEl . setAttribute ( 'data-setup' , JSON . stringify ( { sources : [ blobSrc ] } ) ) ;
143
+ this . player = videojs ( this . mediaEl , {
144
+ enableSourceset : true
145
+ } ) ;
146
+
147
+ this . player . one ( 'sourceset' , ( e ) => {
148
+ validateSource ( this . player , [ blobSrc ] , e ) ;
149
+ done ( ) ;
150
+ } ) ;
151
+ } ) ;
152
+
135
153
QUnit . test ( 'data-setup preload auto' , function ( assert ) {
136
154
const done = assert . async ( ) ;
137
155
@@ -175,6 +193,20 @@ QUnit[qunitFn]('sourceset', function(hooks) {
175
193
} ) ;
176
194
} ) ;
177
195
196
+ QUnit . test ( 'videojs({sources: [...]}) one blob' , function ( assert ) {
197
+ const done = assert . async ( ) ;
198
+
199
+ this . player = videojs ( this . mediaEl , {
200
+ enableSourceset : true ,
201
+ sources : [ blobSrc ]
202
+ } ) ;
203
+
204
+ this . player . one ( 'sourceset' , ( e ) => {
205
+ validateSource ( this . player , [ blobSrc ] , e ) ;
206
+ done ( ) ;
207
+ } ) ;
208
+ } ) ;
209
+
178
210
QUnit . test ( 'videojs({sources: [...]}) two sources' , function ( assert ) {
179
211
const done = assert . async ( ) ;
180
212
@@ -203,6 +235,20 @@ QUnit[qunitFn]('sourceset', function(hooks) {
203
235
} ) ;
204
236
} ) ;
205
237
238
+ QUnit . test ( 'mediaEl.src = blob;' , function ( assert ) {
239
+ const done = assert . async ( ) ;
240
+
241
+ this . mediaEl . src = blobSrc . src ;
242
+ this . player = videojs ( this . mediaEl , {
243
+ enableSourceset : true
244
+ } ) ;
245
+
246
+ this . player . one ( 'sourceset' , ( e ) => {
247
+ validateSource ( this . player , [ { src : blobSrc . src , type : '' } ] , e ) ;
248
+ done ( ) ;
249
+ } ) ;
250
+ } ) ;
251
+
206
252
QUnit . test ( 'mediaEl.setAttribute("src", ...)"' , function ( assert ) {
207
253
const done = assert . async ( ) ;
208
254
@@ -217,6 +263,20 @@ QUnit[qunitFn]('sourceset', function(hooks) {
217
263
} ) ;
218
264
} ) ;
219
265
266
+ QUnit . test ( 'mediaEl.setAttribute("src", blob)' , function ( assert ) {
267
+ const done = assert . async ( ) ;
268
+
269
+ this . mediaEl . setAttribute ( 'src' , blobSrc . src ) ;
270
+ this . player = videojs ( this . mediaEl , {
271
+ enableSourceset : true
272
+ } ) ;
273
+
274
+ this . player . one ( 'sourceset' , ( e ) => {
275
+ validateSource ( this . player , [ { src : blobSrc . src , type : '' } ] , e ) ;
276
+ done ( ) ;
277
+ } ) ;
278
+ } ) ;
279
+
220
280
QUnit . test ( '<source> one source' , function ( assert ) {
221
281
const done = assert . async ( ) ;
222
282
@@ -343,6 +403,20 @@ QUnit[qunitFn]('sourceset', function(hooks) {
343
403
this . player . src ( testSrc ) ;
344
404
} ) ;
345
405
406
+ QUnit . test ( 'player.src({...}) one blob' , function ( assert ) {
407
+ const done = assert . async ( ) ;
408
+
409
+ this . player = videojs ( this . mediaEl , {
410
+ enableSourceset : true
411
+ } ) ;
412
+ this . player . one ( 'sourceset' , ( e ) => {
413
+ validateSource ( this . player , [ blobSrc ] , e ) ;
414
+ done ( ) ;
415
+ } ) ;
416
+
417
+ this . player . src ( blobSrc ) ;
418
+ } ) ;
419
+
346
420
QUnit . test ( 'player.src({...}) preload auto' , function ( assert ) {
347
421
const done = assert . async ( ) ;
348
422
@@ -387,6 +461,19 @@ QUnit[qunitFn]('sourceset', function(hooks) {
387
461
this . player . tech_ . el_ . src = testSrc . src ;
388
462
} ) ;
389
463
464
+ QUnit . test ( 'mediaEl.src = blob' , function ( assert ) {
465
+ const done = assert . async ( ) ;
466
+
467
+ this . player = videojs ( this . mediaEl , { enableSourceset : true } ) ;
468
+
469
+ this . player . one ( 'sourceset' , ( e ) => {
470
+ validateSource ( this . player , [ { src : blobSrc . src , type : '' } ] , e ) ;
471
+ done ( ) ;
472
+ } ) ;
473
+
474
+ this . player . tech_ . el_ . src = blobSrc . src ;
475
+ } ) ;
476
+
390
477
QUnit . test ( 'mediaEl.setAttribute("src", ...)"' , function ( assert ) {
391
478
const done = assert . async ( ) ;
392
479
@@ -400,6 +487,19 @@ QUnit[qunitFn]('sourceset', function(hooks) {
400
487
this . player . tech_ . el_ . setAttribute ( 'src' , testSrc . src ) ;
401
488
} ) ;
402
489
490
+ QUnit . test ( 'mediaEl.setAttribute("src", blob)"' , function ( assert ) {
491
+ const done = assert . async ( ) ;
492
+
493
+ this . player = videojs ( this . mediaEl , { enableSourceset : true } ) ;
494
+
495
+ this . player . one ( 'sourceset' , ( e ) => {
496
+ validateSource ( this . player , [ { src : blobSrc . src , type : '' } ] , e ) ;
497
+ done ( ) ;
498
+ } ) ;
499
+
500
+ this . player . tech_ . el_ . setAttribute ( 'src' , blobSrc . src ) ;
501
+ } ) ;
502
+
403
503
const appendTypes = [
404
504
{ name : 'appendChild' , fn : ( el , obj ) => el . appendChild ( obj ) } ,
405
505
{ name : 'innerHTML' , fn : ( el , obj ) => { el . innerHTML = obj . outerHTML ; } } , // eslint-disable-line
@@ -672,6 +772,113 @@ QUnit[qunitFn]('sourceset', function(hooks) {
672
772
this . player . src ( testSrc ) ;
673
773
} ) ;
674
774
775
+ QUnit . test ( 'hls -> hls -> blob -> hls' , function ( assert ) {
776
+ this . totalSourcesets = 5 ;
777
+ // we have to force techFaker here as some browsers, ie edge/safari support
778
+ // native HLS.
779
+ this . player . options_ . techOrder = [ 'techFaker' ] ;
780
+ this . player . options_ . techFaker = this . player . options_ . techFaker || { } ;
781
+ const done = assert . async ( ) ;
782
+ const m3u8One = {
783
+ src : 'http://vjs.zencdn.net/v/oceans.m3u8' ,
784
+ type : 'application/x-mpegURL'
785
+ } ;
786
+ const blobOne = 'blob:one' ;
787
+ const m3u8Two = {
788
+ src : 'http://vjs.zencdn.net/v/oceans-two.m3u8' ,
789
+ type : 'application/x-mpegURL'
790
+ } ;
791
+ const blobTwo = 'blob:two' ;
792
+ const setTechFaker = ( src ) => {
793
+ this . player . options_ . techFaker = this . player . options_ . techFaker || { } ;
794
+ this . player . tech_ . options_ = this . player . tech_ . options_ || { } ;
795
+ this . player . tech_ . options_ . sourceset = src ;
796
+ this . player . options_ . techFaker . sourceset = src ;
797
+ } ;
798
+
799
+ this . player . one ( 'sourceset' , ( e1 ) => {
800
+ validateSource ( this . player , [ m3u8One ] , e1 , { event : blobOne , attr : blobOne , prop : blobOne } ) ;
801
+
802
+ this . player . one ( 'sourceset' , ( e2 ) => {
803
+ validateSource ( this . player , [ m3u8Two ] , e2 , { event : blobTwo , attr : blobTwo , prop : blobTwo } ) ;
804
+
805
+ // should change to blobSrc now
806
+ this . player . one ( 'sourceset' , ( e3 ) => {
807
+ validateSource ( this . player , [ blobSrc ] , e3 ) ;
808
+
809
+ this . player . one ( 'sourceset' , ( e4 ) => {
810
+ validateSource ( this . player , [ m3u8Two ] , e2 , { event : blobTwo , attr : blobTwo , prop : blobTwo } ) ;
811
+
812
+ done ( ) ;
813
+ } ) ;
814
+
815
+ setTechFaker ( blobTwo ) ;
816
+ this . player . src ( m3u8Two ) ;
817
+ } ) ;
818
+
819
+ setTechFaker ( blobSrc . src ) ;
820
+ this . player . src ( blobSrc ) ;
821
+ } ) ;
822
+
823
+ setTechFaker ( blobTwo ) ;
824
+ this . player . src ( m3u8Two ) ;
825
+ } ) ;
826
+
827
+ setTechFaker ( blobOne ) ;
828
+ this . player . src ( m3u8One ) ;
829
+ } ) ;
830
+
831
+ QUnit . test ( 'hls -> mp4 -> hls -> blob' , function ( assert ) {
832
+ this . totalSourcesets = 5 ;
833
+ // we have to force techFaker here as some browsers, ie edge/safari support
834
+ // native HLS.
835
+ this . player . options_ . techOrder = [ 'techFaker' ] ;
836
+ this . player . options_ . techFaker = this . player . options_ . techFaker || { } ;
837
+ const done = assert . async ( ) ;
838
+ const m3u8One = {
839
+ src : 'http://vjs.zencdn.net/v/oceans.m3u8' ,
840
+ type : 'application/x-mpegURL'
841
+ } ;
842
+ const blobOne = 'blob:one' ;
843
+ const setTechFaker = ( src ) => {
844
+ this . player . options_ . techFaker = this . player . options_ . techFaker || { } ;
845
+ this . player . tech_ . options_ = this . player . tech_ . options_ || { } ;
846
+ this . player . tech_ . options_ . sourceset = src ;
847
+ this . player . options_ . techFaker . sourceset = src ;
848
+ } ;
849
+
850
+ this . player . one ( 'sourceset' , ( e1 ) => {
851
+ validateSource ( this . player , [ m3u8One ] , e1 , { event : blobOne , attr : blobOne , prop : blobOne } ) ;
852
+
853
+ this . player . one ( 'sourceset' , ( e2 ) => {
854
+ validateSource ( this . player , [ testSrc ] , e2 ) ;
855
+
856
+ // should change to blobSrc now
857
+ this . player . one ( 'sourceset' , ( e3 ) => {
858
+ validateSource ( this . player , [ m3u8One ] , e3 , { event : blobOne , attr : blobOne , prop : blobOne } ) ;
859
+
860
+ this . player . one ( 'sourceset' , ( e4 ) => {
861
+ validateSource ( this . player , [ blobSrc ] , e4 ) ;
862
+
863
+ done ( ) ;
864
+ } ) ;
865
+
866
+ setTechFaker ( blobSrc . src ) ;
867
+ this . player . src ( blobSrc ) ;
868
+ } ) ;
869
+
870
+ setTechFaker ( blobOne ) ;
871
+ this . player . src ( m3u8One ) ;
872
+ } ) ;
873
+
874
+ setTechFaker ( testSrc . src ) ;
875
+ this . player . src ( testSrc ) ;
876
+ } ) ;
877
+
878
+ setTechFaker ( blobOne ) ;
879
+ this . player . src ( m3u8One ) ;
880
+ } ) ;
881
+
675
882
QUnit . test ( 'player.src({...}) x2 at the same time' , function ( assert ) {
676
883
const done = assert . async ( ) ;
677
884
0 commit comments