Skip to content

Commit

Permalink
Fixes for Subs / Audio
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba committed Jan 15, 2025
1 parent 799e968 commit 4101377
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions src/TitanVideo/TitanVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,7 @@ function TitanVideo(options) {
onPropChanged('buffering');
onPropChanged('buffered');
};
var loadedSubsAudio = false;
videoElement.onplaying = function() {
if (!loadedSubsAudio) {
loadedSubsAudio = true;
onPropChanged('subtitlesTracks');
onPropChanged('selectedSubtitlesTrackId');
onPropChanged('audioTracks');
onPropChanged('selectedAudioTrackId');
}
onPropChanged('time');
onPropChanged('buffering');
onPropChanged('buffered');
Expand Down Expand Up @@ -499,6 +491,16 @@ function TitanVideo(options) {
}
}

var selectedAudioTrack = getProp('audioTracks')
.find(function(track) {
return track.id === propValue;
});

if (selectedAudioTrack) {
onPropChanged('selectedAudioTrackId');
events.emit('audioTrackLoaded', selectedAudioTrack);
}

break;
}
case 'volume': {
Expand Down Expand Up @@ -541,6 +543,24 @@ function TitanVideo(options) {
onPropChanged('duration');
onPropChanged('buffering');
onPropChanged('buffered');
if (videoElement.textTracks) {
videoElement.textTracks.onaddtrack = function() {
videoElement.textTracks.onaddtrack = null;
setTimeout(function() {
onPropChanged('subtitlesTracks');
onPropChanged('selectedSubtitlesTrackId');
});
}
}
if (videoElement.audioTracks) {
videoElement.audioTracks.onaddtrack = function() {
videoElement.audioTracks.onaddtrack = null;
setTimeout(function() {
onPropChanged('audioTracks');
onPropChanged('selectedAudioTrackId');
});
}
}
videoElement.src = stream.url;
} else {
onError(Object.assign({}, ERROR.UNSUPPORTED_STREAM, {
Expand Down

0 comments on commit 4101377

Please sign in to comment.