|
@@ -243,6 +243,26 @@
|
|
|
return this.appSettings.get('volume') || 1;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @private
|
|
|
+ */
|
|
|
+ getRelativeIndexByType(mediaStreams, jellyIndex, streamType) {
|
|
|
+ let relIndex = 1;
|
|
|
+ for (const source of mediaStreams) {
|
|
|
+ if (source.Type != streamType || source.IsExternal) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (source.Index == jellyIndex) {
|
|
|
+ return relIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ relIndex += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @private
|
|
|
*/
|
|
@@ -262,7 +282,43 @@
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
- return '#' + this._subtitleTrackIndexToSetOnPlaying;
|
|
|
+ const subtitleRelIndex = this.getRelativeIndexByType(
|
|
|
+ options.mediaSource.MediaStreams,
|
|
|
+ this._subtitleTrackIndexToSetOnPlaying,
|
|
|
+ 'Subtitle'
|
|
|
+ );
|
|
|
+
|
|
|
+ return subtitleRelIndex != null
|
|
|
+ ? '#' + subtitleRelIndex
|
|
|
+ : '';
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @private
|
|
|
+ */
|
|
|
+ getAudioParam() {
|
|
|
+ const options = this._currentPlayOptions;
|
|
|
+
|
|
|
+ if (this._audioTrackIndexToSetOnPlaying != null && this._audioTrackIndexToSetOnPlaying >= 0) {
|
|
|
+ const initialAudioStream = options.mediaSource.MediaStreams[this._audioTrackIndexToSetOnPlaying];
|
|
|
+ if (!initialAudioStream) {
|
|
|
+ return '#1';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this._audioTrackIndexToSetOnPlaying == -1 || this._audioTrackIndexToSetOnPlaying == null) {
|
|
|
+ return '#1';
|
|
|
+ }
|
|
|
+
|
|
|
+ const audioRelIndex = this.getRelativeIndexByType(
|
|
|
+ options.mediaSource.MediaStreams,
|
|
|
+ this._audioTrackIndexToSetOnPlaying,
|
|
|
+ 'Audio'
|
|
|
+ );
|
|
|
+
|
|
|
+ return audioRelIndex != null
|
|
|
+ ? '#' + audioRelIndex
|
|
|
+ : '#1';
|
|
|
}
|
|
|
|
|
|
tryGetFramerate(options) {
|
|
@@ -300,8 +356,7 @@
|
|
|
player.load(val,
|
|
|
{ startMilliseconds: ms, autoplay: true },
|
|
|
streamdata,
|
|
|
- (this._audioTrackIndexToSetOnPlaying != null)
|
|
|
- ? '#' + this._audioTrackIndexToSetOnPlaying : '#1',
|
|
|
+ this.getAudioParam(),
|
|
|
this.getSubtitleParam(),
|
|
|
resolve);
|
|
|
});
|
|
@@ -367,7 +422,7 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- window.api.player.setAudioStream(index != -1 ? '#' + index : '');
|
|
|
+ window.api.player.setAudioStream(this.getAudioParam());
|
|
|
}
|
|
|
|
|
|
onEndedInternal() {
|