feat: Improved movie playback and listing stream options

This commit is contained in:
Aleksi Lassila
2024-12-10 03:32:51 +02:00
parent 96d52299b0
commit 1f7f74a8a7
13 changed files with 558 additions and 188 deletions

View File

@@ -11,6 +11,7 @@
export let tmdbId: string;
export let sourceId: string;
export let key: string = '';
export let modalId: symbol;
export let hidden: boolean = false;
@@ -32,12 +33,19 @@
const refreshVideoStream = async (audioStreamIndex = 0) => {
console.log('called2');
videoStreamP = reiverrApiNew.movies
.getMovieStream(sourceId, tmdbId, {
// bitrate: getQualities(1080)?.[0]?.maxBitrate || 10000000,
progress: 0,
audioStreamIndex,
deviceProfile: getDeviceProfile() as any
})
.getMovieStream(
tmdbId,
sourceId,
{
key
},
{
// bitrate: getQualities(1080)?.[0]?.maxBitrate || 10000000,
progress: 0,
audioStreamIndex,
deviceProfile: getDeviceProfile() as any
}
)
.then((r) => r.data)
.then((d) => ({
...d,

View File

@@ -1,4 +1,4 @@
import { writable } from 'svelte/store';
import { get, writable } from 'svelte/store';
import { modalStack } from '../Modal/modal.store';
import { jellyfinItemsStore } from '../../stores/data.store';
import JellyfinVideoPlayerModal from './JellyfinVideoPlayerModal.svelte';
@@ -49,10 +49,17 @@ export type PlayerStateValue = typeof initialValue;
function usePlayerState() {
const store = writable<PlayerStateValue>(initialValue);
async function streamMovie(tmdbId: string, sourceId: string = '') {
async function streamMovie(tmdbId: string, sourceId: string = '', key: string = '') {
if (!sourceId) {
const sources = await reiverrApiNew.movies.getMovieSources(tmdbId).then((r) => r.data);
sourceId = Object.keys(sources.sources)[0] || '';
const streams = await Promise.all(
get(sources).map((s) =>
reiverrApiNew.movies
.getMovieStreams(tmdbId, s.id)
.then((r) => ({ source: s, streams: r.data.streams }))
)
);
sourceId = streams?.[0]?.source.id || '';
key = streams?.[0]?.streams?.[0]?.key || '';
}
if (!sourceId) {
@@ -63,7 +70,8 @@ function usePlayerState() {
store.set({ visible: true, jellyfinId: tmdbId, sourceId });
modalStack.create(MovieVideoPlayerModal, {
tmdbId,
sourceId
sourceId,
key
});
}