@@ -77,6 +77,15 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
77
77
/** @private {boolean} */
78
78
this . androidReceiverCompatible_ = androidReceiverCompatible ;
79
79
80
+ /** @private {!Array<?>} */
81
+ this . addThumbnailsTrackCalls_ = [ ] ;
82
+
83
+ /** @private {!Array<?>} */
84
+ this . addTextTrackAsyncCalls_ = [ ] ;
85
+
86
+ /** @private {!Array<?>} */
87
+ this . addChaptersTrackCalls_ = [ ] ;
88
+
80
89
/** @private {!Map} */
81
90
this . compiledToExternNames_ = new Map ( ) ;
82
91
@@ -205,7 +214,6 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
205
214
return ;
206
215
}
207
216
// TODO: transfer manually-selected tracks?
208
- // TODO: transfer side-loaded text tracks?
209
217
210
218
await this . sender_ . cast ( ) ;
211
219
if ( ! this . localPlayer_ ) {
@@ -450,6 +458,9 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
450
458
'playerAfterLoad' : { } ,
451
459
'manifest' : this . localPlayer_ . getAssetUri ( ) ,
452
460
'startTime' : null ,
461
+ 'addThumbnailsTrackCalls' : this . addThumbnailsTrackCalls_ ,
462
+ 'addTextTrackAsyncCalls' : this . addTextTrackAsyncCalls_ ,
463
+ 'addChaptersTrackCalls' : this . addChaptersTrackCalls_ ,
453
464
} ;
454
465
455
466
// Pause local playback before capturing state.
@@ -517,6 +528,12 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
517
528
/** @type {Object } */ ( this . localPlayer_ ) [ setter ] ( value ) ;
518
529
}
519
530
531
+ const addThumbnailsTrackCalls = this . addThumbnailsTrackCalls_ ;
532
+ const addTextTrackAsyncCalls = this . addTextTrackAsyncCalls_ ;
533
+ const addChaptersTrackCalls = this . addChaptersTrackCalls_ ;
534
+
535
+ this . resetExternalTracks ( ) ;
536
+
520
537
// Get the most recent manifest URI and ended state.
521
538
const assetUri = this . sender_ . get ( 'player' , 'getAssetUri' ) ( ) ;
522
539
const ended = this . sender_ . get ( 'video' , 'ended' ) ;
@@ -562,6 +579,16 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
562
579
return ;
563
580
}
564
581
582
+ for ( const args of addThumbnailsTrackCalls ) {
583
+ this . localPlayer_ . addThumbnailsTrack ( ...args ) ;
584
+ }
585
+ for ( const args of addTextTrackAsyncCalls ) {
586
+ this . localPlayer_ . addTextTrackAsync ( ...args ) ;
587
+ }
588
+ for ( const args of addChaptersTrackCalls ) {
589
+ this . localPlayer_ . addChaptersTrack ( ...args ) ;
590
+ }
591
+
565
592
for ( const name of shaka . cast . CastUtils . VideoInitStateAttributes ) {
566
593
this . localVideo_ [ name ] = videoState [ name ] ;
567
594
}
@@ -672,10 +699,11 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
672
699
673
700
/**
674
701
* @param {string } name
702
+ * @param {boolean } dontRecordCalls
675
703
* @return {? }
676
704
* @private
677
705
*/
678
- playerProxyGet_ ( name ) {
706
+ playerProxyGet_ ( name , dontRecordCalls = false ) {
679
707
// If name is a shortened compiled name, get the original version
680
708
// from our map.
681
709
if ( this . compiledToExternNames_ . has ( name ) ) {
@@ -739,6 +767,27 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
739
767
return ( container ) => this . localPlayer_ . setVideoContainer ( container ) ;
740
768
}
741
769
770
+ if ( ! dontRecordCalls ) {
771
+ if ( name == 'addThumbnailsTrack' ) {
772
+ return ( ...args ) => {
773
+ this . addThumbnailsTrackCalls_ . push ( args ) ;
774
+ return this . playerProxyGet_ ( name , /* dontRecordCalls= */ true ) ( args ) ;
775
+ } ;
776
+ }
777
+ if ( name == 'addTextTrackAsync' ) {
778
+ return ( ...args ) => {
779
+ this . addTextTrackAsyncCalls_ . push ( args ) ;
780
+ return this . playerProxyGet_ ( name , /* dontRecordCalls= */ true ) ( args ) ;
781
+ } ;
782
+ }
783
+ if ( name == 'addChaptersTrack' ) {
784
+ return ( ...args ) => {
785
+ this . addChaptersTrackCalls_ . push ( args ) ;
786
+ return this . playerProxyGet_ ( name , /* dontRecordCalls= */ true ) ( args ) ;
787
+ } ;
788
+ }
789
+ }
790
+
742
791
if ( this . sender_ . isCasting ( ) ) {
743
792
// These methods are unavailable or otherwise stubbed during casting.
744
793
if ( name == 'getManifest' || name == 'drmInfo' ) {
@@ -820,7 +869,19 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
820
869
if ( targetName == 'video' ) {
821
870
this . videoEventTarget_ . dispatchEvent ( event ) ;
822
871
} else if ( targetName == 'player' ) {
872
+ if ( event . type == shaka . util . FakeEvent . EventName . Unloading ) {
873
+ this . resetExternalTracks ( ) ;
874
+ }
823
875
this . playerEventTarget_ . dispatchEvent ( event ) ;
824
876
}
825
877
}
878
+
879
+ /**
880
+ * Reset external tracks
881
+ */
882
+ resetExternalTracks ( ) {
883
+ this . addThumbnailsTrackCalls_ = [ ] ;
884
+ this . addTextTrackAsyncCalls_ = [ ] ;
885
+ this . addChaptersTrackCalls_ = [ ] ;
886
+ }
826
887
} ;
0 commit comments