Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #181 from ttshivers/subtitle_fixes
Browse files Browse the repository at this point in the history
fix(subtitles): use metadata stream codec when direct playing subtitles
  • Loading branch information
ttshivers authored Sep 27, 2020
2 parents 1a77470 + b9a04d4 commit f80e701
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
34 changes: 27 additions & 7 deletions src/store/modules/slplayer/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export default {
?.find(({ streamType, selected }) => streamType === 3 && selected),

CAN_DIRECT_PLAY_SUBTITLES: (state, getters) => {
if (getters.SHOULD_FORCE_BURN_SUBTITLES) {
return false;
}

const { key, codec } = getters.GET_SELECTED_SUBTITLE_STREAM;
// TODO: examine if I can only direct play with sidecar subtitles
return key && (codec === 'srt' || codec === 'ass');
Expand All @@ -104,8 +108,8 @@ export default {
}

if (getters.GET_SELECTED_SUBTITLE_STREAM) {
if (getters.IS_IN_PICTURE_IN_PICTURE) {
console.debug('CAN_DIRECT_PLAY: false because subtitles enabled and using PIP');
if (getters.SHOULD_FORCE_BURN_SUBTITLES) {
console.debug('CAN_DIRECT_PLAY: false because subtitles are set to be burned');
return false;
}

Expand Down Expand Up @@ -218,6 +222,26 @@ export default {
: base;
},

SHOULD_FORCE_BURN_SUBTITLES: (state, getters) => getters.IS_IN_PICTURE_IN_PICTURE,

GET_SUBTITLE_PARAMS: (state, getters) => {
if (!getters.GET_SELECTED_SUBTITLE_STREAM || getters.CAN_DIRECT_PLAY
|| getters.CAN_DIRECT_PLAY_SUBTITLES) {
return null;
}

if (getters.SHOULD_FORCE_BURN_SUBTITLES) {
return {
subtitles: 'burn',
};
}

return {
subtitles: 'auto',
advancedSubtitles: 'text',
};
},

GET_DECISION_AND_START_PARAMS: (state, getters, rootState, rootGetters) => ({
hasMDE: 1,
path: rootGetters['plexclients/GET_ACTIVE_MEDIA_METADATA'].key,
Expand All @@ -242,11 +266,7 @@ export default {
directStreamAudio: getters.GET_FORCE_TRANSCODE ? 0 : 1,
mediaBufferSize: 102400, // ~100MB (same as what Plex Web uses)
session: state.session,
// eslint-disable-next-line no-nested-ternary
subtitles: getters.CAN_DIRECT_PLAY
? 'none'
: getters.IS_IN_PICTURE_IN_PICTURE ? 'burn' : 'auto',
...(!getters.IS_IN_PICTURE_IN_PICTURE && { advancedSubtitles: 'text' }),
...getters.GET_SUBTITLE_PARAMS,
'Accept-Language': 'en',
'X-Plex-Session-Identifier': getters.GET_X_PLEX_SESSION_ID,
'X-Plex-Client-Profile-Extra': getters.GET_PLEX_PROFILE_EXTRAS,
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/slplayer/subtitleActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ export default {
);

const useSrtParser = getters.CAN_DIRECT_PLAY_SUBTITLES
&& getters.GET_SUBTITLE_STREAM.codec === 'srt';
&& (getters.GET_SUBTITLE_STREAM.codec === 'srt'
|| getters.GET_SELECTED_SUBTITLE_STREAM.codec === 'srt');

const parser = useSrtParser
? new libjass.parser.SrtStreamParser(stream)
Expand Down

0 comments on commit f80e701

Please sign in to comment.