Skip to content

Commit

Permalink
Return MediaStream type from getStreamByIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex committed Dec 8, 2024
1 parent 9b7cbb0 commit 299c43e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 8 additions & 4 deletions src/components/maincontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,17 @@ export function setSubtitleStreamIndex(
subtitleStream.DeliveryMethod == 'External' ||
currentDeliveryMethod == 'Encode'
) {
const textStreamUrl = subtitleStream.IsExternalUrl
? subtitleStream.DeliveryUrl
: JellyfinApi.createUrl(subtitleStream.DeliveryUrl);
let textStreamUrl;

if (subtitleStream.IsExternal && subtitleStream.DeliveryUrl) {
textStreamUrl = subtitleStream.DeliveryUrl;
} else if (subtitleStream.DeliveryUrl) {
textStreamUrl = JellyfinApi.createUrl(subtitleStream.DeliveryUrl);
}

console.log(`Subtitle url: ${textStreamUrl}`);
setTextTrack(index);
state.subtitleStreamIndex = subtitleStream.Index;
state.subtitleStreamIndex = subtitleStream.Index ?? null;

return;
} else {
Expand Down
13 changes: 7 additions & 6 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,18 @@ export function createStreamInfo(
* @param streams - array streams to consider
* @param type - type of stream
* @param index - index of stream
* @returns first first matching stream
* @returns first matching stream
*/
export function getStreamByIndex(
streams: MediaStream[],
type: string,
index: number
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): any {
return streams.find((s) => {
return s.Type == type && s.Index == index;
});
): MediaStream {
return (
streams.find((s) => {
return s.Type == type && s.Index == index;
}) ?? {}
);
}

// defined for use in the 3 next functions
Expand Down

0 comments on commit 299c43e

Please sign in to comment.