@@ -58,15 +58,7 @@ function TitanVideo(options) {
58
58
onPropChanged ( 'buffering' ) ;
59
59
onPropChanged ( 'buffered' ) ;
60
60
} ;
61
- var loadedSubsAudio = false ;
62
61
videoElement . onplaying = function ( ) {
63
- if ( ! loadedSubsAudio ) {
64
- loadedSubsAudio = true ;
65
- onPropChanged ( 'subtitlesTracks' ) ;
66
- onPropChanged ( 'selectedSubtitlesTrackId' ) ;
67
- onPropChanged ( 'audioTracks' ) ;
68
- onPropChanged ( 'selectedAudioTrackId' ) ;
69
- }
70
62
onPropChanged ( 'time' ) ;
71
63
onPropChanged ( 'buffering' ) ;
72
64
onPropChanged ( 'buffered' ) ;
@@ -499,6 +491,16 @@ function TitanVideo(options) {
499
491
}
500
492
}
501
493
494
+ var selectedAudioTrack = getProp ( 'audioTracks' )
495
+ . find ( function ( track ) {
496
+ return track . id === propValue ;
497
+ } ) ;
498
+
499
+ if ( selectedAudioTrack ) {
500
+ onPropChanged ( 'selectedAudioTrackId' ) ;
501
+ events . emit ( 'audioTrackLoaded' , selectedAudioTrack ) ;
502
+ }
503
+
502
504
break ;
503
505
}
504
506
case 'volume' : {
@@ -541,6 +543,24 @@ function TitanVideo(options) {
541
543
onPropChanged ( 'duration' ) ;
542
544
onPropChanged ( 'buffering' ) ;
543
545
onPropChanged ( 'buffered' ) ;
546
+ if ( videoElement . textTracks ) {
547
+ videoElement . textTracks . onaddtrack = function ( ) {
548
+ videoElement . textTracks . onaddtrack = null ;
549
+ setTimeout ( function ( ) {
550
+ onPropChanged ( 'subtitlesTracks' ) ;
551
+ onPropChanged ( 'selectedSubtitlesTrackId' ) ;
552
+ } ) ;
553
+ }
554
+ }
555
+ if ( videoElement . audioTracks ) {
556
+ videoElement . audioTracks . onaddtrack = function ( ) {
557
+ videoElement . audioTracks . onaddtrack = null ;
558
+ setTimeout ( function ( ) {
559
+ onPropChanged ( 'audioTracks' ) ;
560
+ onPropChanged ( 'selectedAudioTrackId' ) ;
561
+ } ) ;
562
+ }
563
+ }
544
564
videoElement . src = stream . url ;
545
565
} else {
546
566
onError ( Object . assign ( { } , ERROR . UNSUPPORTED_STREAM , {
0 commit comments