mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
Fix playback not working for offline content
This commit is contained in:
@@ -550,7 +550,7 @@ export default function page() {
|
||||
source={{
|
||||
uri: stream?.url || "",
|
||||
autoplay: true,
|
||||
isNetwork: true,
|
||||
isNetwork: !offline,
|
||||
startPosition,
|
||||
externalSubtitles,
|
||||
initOptions,
|
||||
|
||||
@@ -143,7 +143,7 @@ extension VLCPlayerWrapper: VLCMediaPlayerDelegate {
|
||||
guard let vlcPlayerView = self.playerView.superview as? VlcPlayerView,
|
||||
!vlcPlayerView.initialSeekPerformed,
|
||||
vlcPlayerView.startPosition > 0,
|
||||
vlcPlayerView.isTranscoding,
|
||||
vlcPlayerView.shouldPerformInitialSeek,
|
||||
player.isSeekable else { return }
|
||||
vlcPlayerView.initialSeekPerformed = true
|
||||
// Use a logger from the VlcPlayerView if available, or create a new one
|
||||
@@ -167,7 +167,9 @@ class VlcPlayerView: ExpoView {
|
||||
private var externalSubtitles: [[String: String]]?
|
||||
var hasSource = false
|
||||
var initialSeekPerformed = false
|
||||
var isTranscoding: Bool = false
|
||||
// A flag variable determinging if we should perform the initial seek. Its either transcoding or offline playback. that makes
|
||||
var shouldPerformInitialSeek: Bool = false
|
||||
|
||||
|
||||
// MARK: - Initialization
|
||||
required init(appContext: AppContext? = nil) {
|
||||
@@ -265,12 +267,11 @@ class VlcPlayerView: ExpoView {
|
||||
return
|
||||
}
|
||||
|
||||
if uri.contains("m3u8") {
|
||||
self.isTranscoding = true
|
||||
}
|
||||
let autoplay = source["autoplay"] as? Bool ?? false
|
||||
let isNetwork = source["isNetwork"] as? Bool ?? false
|
||||
|
||||
// Set shouldPeformIntial based on isTranscoding and is not a network stream
|
||||
self.shouldPerformInitialSeek = uri.contains("m3u8") || !isNetwork
|
||||
self.onVideoLoadStart?(["target": self.reactTag ?? NSNull()])
|
||||
|
||||
let media: VLCMedia!
|
||||
@@ -295,7 +296,7 @@ class VlcPlayerView: ExpoView {
|
||||
if autoplay {
|
||||
logger.info("Playing...")
|
||||
// The Video is not transcoding so it its safe to seek to the start position.
|
||||
if !self.isTranscoding {
|
||||
if !self.shouldPerformInitialSeek {
|
||||
self.vlc.player.time = VLCTime(number: NSNumber(value: self.startPosition * 1000))
|
||||
}
|
||||
self.play()
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import generateDeviceProfile from "@/utils/profiles/native";
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type {
|
||||
BaseItemDto,
|
||||
MediaSourceInfo,
|
||||
PlaybackInfoResponse,
|
||||
} from "@jellyfin/sdk/lib/generated-client/models";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api";
|
||||
import { Alert } from "react-native";
|
||||
import generateDeviceProfile from "@/utils/profiles/native";
|
||||
|
||||
export const getStreamUrl = async ({
|
||||
api,
|
||||
@@ -33,7 +31,7 @@ export const getStreamUrl = async ({
|
||||
subtitleStreamIndex?: number;
|
||||
height?: number;
|
||||
mediaSourceId?: string | null;
|
||||
download?: bool;
|
||||
download?: boolean;
|
||||
deviceId?: string | null;
|
||||
}): Promise<{
|
||||
url: string | null;
|
||||
@@ -73,8 +71,8 @@ export const getStreamUrl = async ({
|
||||
}
|
||||
|
||||
sessionId = res.data.PlaySessionId || null;
|
||||
mediaSource = res.data.MediaSources[0];
|
||||
let transcodeUrl = mediaSource.TranscodingUrl;
|
||||
mediaSource = res.data.MediaSources?.[0];
|
||||
let transcodeUrl = mediaSource?.TranscodingUrl;
|
||||
|
||||
if (transcodeUrl) {
|
||||
if (download) {
|
||||
@@ -125,7 +123,7 @@ export const getStreamUrl = async ({
|
||||
|
||||
return {
|
||||
url: directPlayUrl,
|
||||
sessionId: sessionId || playSessionId,
|
||||
sessionId: sessionId || playSessionId || null,
|
||||
mediaSource,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ export const generateDeviceProfile = async () => {
|
||||
DirectPlayProfiles: [
|
||||
{
|
||||
Type: MediaTypes.Video,
|
||||
Container: "mp4,mkv,avi,mov,flv,ts,m2ts,webm,ogv,3gp,hls",
|
||||
Container: "mkv,avi,mov,flv,ts,m2ts,webm,ogv,3gp,hls",
|
||||
VideoCodec:
|
||||
"h264,hevc,mpeg4,divx,xvid,wmv,vc1,vp8,vp9,av1,avi,mpeg,mpeg2video",
|
||||
AudioCodec: "aac,ac3,eac3,mp3,flac,alac,opus,vorbis,wma,dts",
|
||||
|
||||
Reference in New Issue
Block a user