mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 23:59:08 +00:00
Merge branch 'feature/vlc-support' of https://github.com/Alexk2309/streamyfin into pr/178
This commit is contained in:
@@ -17,7 +17,7 @@ import { getBackdropUrl } from "@/utils/jellyfin/image/getBackdropUrl";
|
||||
import { getStreamUrl } from "@/utils/jellyfin/media/getStreamUrl";
|
||||
import { writeToLog } from "@/utils/log";
|
||||
import native from "@/utils/profiles/native";
|
||||
import { msToTicks } from "@/utils/time";
|
||||
import { msToTicks, ticksToMs } from "@/utils/time";
|
||||
import { Api } from "@jellyfin/sdk";
|
||||
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import {
|
||||
@@ -28,7 +28,13 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import * as Haptics from "expo-haptics";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { useAtomValue } from "jotai";
|
||||
import React, { useCallback, useMemo, useRef, useState } from "react";
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import {
|
||||
Alert,
|
||||
Pressable,
|
||||
@@ -146,7 +152,8 @@ export default function page() {
|
||||
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
||||
if (isPlaying) {
|
||||
videoRef.current?.pause();
|
||||
await videoRef.current?.pause();
|
||||
|
||||
await getPlaystateApi(api).onPlaybackProgress({
|
||||
itemId: item?.Id!,
|
||||
audioStreamIndex: audioIndex ? audioIndex : undefined,
|
||||
@@ -159,6 +166,7 @@ export default function page() {
|
||||
: "DirectStream",
|
||||
playSessionId: stream.sessionId,
|
||||
});
|
||||
console.log("ACtually marked as paused");
|
||||
} else {
|
||||
videoRef.current?.play();
|
||||
await getPlaystateApi(api).onPlaybackProgress({
|
||||
@@ -230,7 +238,7 @@ export default function page() {
|
||||
if (isPlaybackStopped === true) return;
|
||||
if (!item?.Id || !api || !stream) return;
|
||||
|
||||
const { currentTime, isPlaying } = data.nativeEvent;
|
||||
const { currentTime } = data.nativeEvent;
|
||||
|
||||
progress.value = currentTime;
|
||||
const currentTimeInTicks = msToTicks(currentTime);
|
||||
@@ -251,6 +259,7 @@ export default function page() {
|
||||
playMethod: stream?.url.includes("m3u8") ? "Transcode" : "DirectStream",
|
||||
playSessionId: stream.sessionId,
|
||||
});
|
||||
console.log("Progress", currentTime);
|
||||
},
|
||||
[item?.Id, isPlaying, api, isPlaybackStopped]
|
||||
);
|
||||
@@ -313,6 +322,10 @@ export default function page() {
|
||||
|
||||
if (!stream || !item) return null;
|
||||
|
||||
const startPosition = item?.UserData?.PlaybackPositionTicks
|
||||
? ticksToMs(item.UserData.PlaybackPositionTicks)
|
||||
: 0;
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@@ -335,7 +348,7 @@ export default function page() {
|
||||
uri: stream.url,
|
||||
autoplay: true,
|
||||
isNetwork: true,
|
||||
startPosition: 0,
|
||||
startPosition,
|
||||
}}
|
||||
style={{ width: "100%", height: "100%" }}
|
||||
onVideoProgress={onProgress}
|
||||
@@ -382,7 +395,7 @@ export default function page() {
|
||||
setSubtitleTrack={videoRef.current.setSubtitleTrack}
|
||||
setSubtitleURL={videoRef.current.setSubtitleURL}
|
||||
setAudioTrack={videoRef.current.setAudioTrack}
|
||||
stop={videoRef.current.stop}
|
||||
stop={videoRef.current?.stop}
|
||||
isVlc
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -226,7 +226,9 @@ export const Controls: React.FC<Props> = ({
|
||||
isSeeking.value = false;
|
||||
progress.value = value;
|
||||
|
||||
await seek(Math.max(0, Math.floor(isVlc ? value : value / 10000000)));
|
||||
await seek(
|
||||
Math.max(0, Math.floor(isVlc ? value : ticksToSeconds(value)))
|
||||
);
|
||||
if (wasPlayingRef.current === true) play();
|
||||
},
|
||||
[isVlc]
|
||||
|
||||
@@ -165,13 +165,13 @@ class VlcPlayerView: ExpoView {
|
||||
|
||||
self.mediaPlayer?.media = media
|
||||
|
||||
if startPosition > 0 {
|
||||
self.mediaPlayer?.time = VLCTime(int: startPosition)
|
||||
}
|
||||
|
||||
if autoplay {
|
||||
print("Playing...")
|
||||
self.play()
|
||||
if startPosition > 0 {
|
||||
print("Debug: Starting at position: \(startPosition)")
|
||||
self.seekTo(startPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user