mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-20 21:00:25 +01:00
Compare commits
1 Commits
fix/extern
...
lint/remov
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cce8672898 |
@@ -1,5 +1,4 @@
|
|||||||
import type { TrackInfo } from "@/modules/VlcPlayer.types";
|
import type { TrackInfo } from "@/modules/VlcPlayer.types";
|
||||||
import { VideoPlayer, useSettings } from "@/utils/atoms/settings";
|
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
import {
|
import {
|
||||||
@@ -48,7 +47,6 @@ export const VideoProvider: React.FC<VideoProviderProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [audioTracks, setAudioTracks] = useState<Track[] | null>(null);
|
const [audioTracks, setAudioTracks] = useState<Track[] | null>(null);
|
||||||
const [subtitleTracks, setSubtitleTracks] = useState<Track[] | null>(null);
|
const [subtitleTracks, setSubtitleTracks] = useState<Track[] | null>(null);
|
||||||
const [settings] = useSettings();
|
|
||||||
|
|
||||||
const ControlContext = useControlContext();
|
const ControlContext = useControlContext();
|
||||||
const isVideoLoaded = ControlContext?.isVideoLoaded;
|
const isVideoLoaded = ControlContext?.isVideoLoaded;
|
||||||
@@ -134,7 +132,7 @@ export const VideoProvider: React.FC<VideoProviderProps> = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Step 2: Apply VLC indexing logic
|
// Step 2: Apply VLC indexing logic
|
||||||
let textSubIndex = settings.defaultPlayer === VideoPlayer.VLC_4 ? 0 : 1;
|
let textSubIndex = 0;
|
||||||
const processedSubs: Track[] = sortedSubs?.map((sub) => {
|
const processedSubs: Track[] = sortedSubs?.map((sub) => {
|
||||||
// Always increment for non-transcoding subtitles
|
// Always increment for non-transcoding subtitles
|
||||||
// Only increment for text-based subtitles when transcoding
|
// Only increment for text-based subtitles when transcoding
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import ExpoModulesCore
|
import ExpoModulesCore
|
||||||
|
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
import TVVLCKit
|
import TVVLCKit
|
||||||
#else
|
#else
|
||||||
import MobileVLCKit
|
import MobileVLCKit
|
||||||
#endif
|
#endif
|
||||||
|
import UIKit
|
||||||
|
|
||||||
class VlcPlayer3View: ExpoView {
|
class VlcPlayer3View: ExpoView {
|
||||||
private var mediaPlayer: VLCMediaPlayer?
|
private var mediaPlayer: VLCMediaPlayer?
|
||||||
@@ -16,7 +16,7 @@ class VlcPlayer3View: ExpoView {
|
|||||||
private var lastReportedIsPlaying: Bool?
|
private var lastReportedIsPlaying: Bool?
|
||||||
private var customSubtitles: [(internalName: String, originalName: String)] = []
|
private var customSubtitles: [(internalName: String, originalName: String)] = []
|
||||||
private var startPosition: Int32 = 0
|
private var startPosition: Int32 = 0
|
||||||
private var externalSubtitles: [[String: String]]?
|
private var isMediaReady: Bool = false
|
||||||
private var externalTrack: [String: String]?
|
private var externalTrack: [String: String]?
|
||||||
private var progressTimer: DispatchSourceTimer?
|
private var progressTimer: DispatchSourceTimer?
|
||||||
private var isStopping: Bool = false // Define isStopping here
|
private var isStopping: Bool = false // Define isStopping here
|
||||||
@@ -61,7 +61,7 @@ class VlcPlayer3View: ExpoView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Public Methods
|
// MARK: - Public Methods
|
||||||
func startPictureInPicture() {}
|
func startPictureInPicture() { }
|
||||||
|
|
||||||
@objc func play() {
|
@objc func play() {
|
||||||
self.mediaPlayer?.play()
|
self.mediaPlayer?.play()
|
||||||
@@ -109,7 +109,6 @@ class VlcPlayer3View: ExpoView {
|
|||||||
self.externalTrack = source["externalTrack"] as? [String: String]
|
self.externalTrack = source["externalTrack"] as? [String: String]
|
||||||
var initOptions = source["initOptions"] as? [Any] ?? []
|
var initOptions = source["initOptions"] as? [Any] ?? []
|
||||||
self.startPosition = source["startPosition"] as? Int32 ?? 0
|
self.startPosition = source["startPosition"] as? Int32 ?? 0
|
||||||
self.externalSubtitles = source["externalSubtitles"] as? [[String: String]]
|
|
||||||
initOptions.append("--start-time=\(self.startPosition)")
|
initOptions.append("--start-time=\(self.startPosition)")
|
||||||
|
|
||||||
guard let uri = source["uri"] as? String, !uri.isEmpty else {
|
guard let uri = source["uri"] as? String, !uri.isEmpty else {
|
||||||
@@ -144,8 +143,8 @@ class VlcPlayer3View: ExpoView {
|
|||||||
media.addOptions(mediaOptions)
|
media.addOptions(mediaOptions)
|
||||||
|
|
||||||
self.mediaPlayer?.media = media
|
self.mediaPlayer?.media = media
|
||||||
self.setInitialExternalSubtitles()
|
|
||||||
self.hasSource = true
|
self.hasSource = true
|
||||||
|
|
||||||
if autoplay {
|
if autoplay {
|
||||||
print("Playing...")
|
print("Playing...")
|
||||||
self.play()
|
self.play()
|
||||||
@@ -183,9 +182,9 @@ class VlcPlayer3View: ExpoView {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = self.mediaPlayer?.addPlaybackSlave(url, type: .subtitle, enforce: false)
|
let result = self.mediaPlayer?.addPlaybackSlave(url, type: .subtitle, enforce: true)
|
||||||
if let result = result {
|
if let result = result {
|
||||||
let internalName = "Track \(self.customSubtitles.count)"
|
let internalName = "Track \(self.customSubtitles.count + 1)"
|
||||||
print("Subtitle added with result: \(result) \(internalName)")
|
print("Subtitle added with result: \(result) \(internalName)")
|
||||||
self.customSubtitles.append((internalName: internalName, originalName: name))
|
self.customSubtitles.append((internalName: internalName, originalName: name))
|
||||||
} else {
|
} else {
|
||||||
@@ -193,19 +192,6 @@ class VlcPlayer3View: ExpoView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setInitialExternalSubtitles() {
|
|
||||||
if let externalSubtitles = self.externalSubtitles {
|
|
||||||
for subtitle in externalSubtitles {
|
|
||||||
if let subtitleName = subtitle["name"],
|
|
||||||
let subtitleURL = subtitle["DeliveryUrl"]
|
|
||||||
{
|
|
||||||
print("Setting external subtitle: \(subtitleName) \(subtitleURL)")
|
|
||||||
self.setSubtitleURL(subtitleURL, name: subtitleName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func getSubtitleTracks() -> [[String: Any]]? {
|
@objc func getSubtitleTracks() -> [[String: Any]]? {
|
||||||
guard let mediaPlayer = self.mediaPlayer else {
|
guard let mediaPlayer = self.mediaPlayer else {
|
||||||
return nil
|
return nil
|
||||||
@@ -290,6 +276,16 @@ class VlcPlayer3View: ExpoView {
|
|||||||
|
|
||||||
print("Debug: Current time: \(currentTimeMs)")
|
print("Debug: Current time: \(currentTimeMs)")
|
||||||
if currentTimeMs >= 0 && currentTimeMs < durationMs {
|
if currentTimeMs >= 0 && currentTimeMs < durationMs {
|
||||||
|
if player.isPlaying && !self.isMediaReady {
|
||||||
|
self.isMediaReady = true
|
||||||
|
// Set external track subtitle when starting.
|
||||||
|
if let externalTrack = self.externalTrack {
|
||||||
|
if let name = externalTrack["name"], !name.isEmpty {
|
||||||
|
let deliveryUrl = externalTrack["DeliveryUrl"] ?? ""
|
||||||
|
self.setSubtitleURL(deliveryUrl, name: name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
self.onVideoProgress?([
|
self.onVideoProgress?([
|
||||||
"currentTime": currentTimeMs,
|
"currentTime": currentTimeMs,
|
||||||
"duration": durationMs,
|
"duration": durationMs,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ Pod::Spec.new do |s|
|
|||||||
s.dependency 'ExpoModulesCore'
|
s.dependency 'ExpoModulesCore'
|
||||||
s.ios.dependency 'VLCKit', s.version
|
s.ios.dependency 'VLCKit', s.version
|
||||||
s.tvos.dependency 'VLCKit', s.version
|
s.tvos.dependency 'VLCKit', s.version
|
||||||
s.dependency 'Alamofire', '~> 5.10'
|
|
||||||
|
|
||||||
# Swift/Objective-C compatibility
|
# Swift/Objective-C compatibility
|
||||||
s.pod_target_xcconfig = {
|
s.pod_target_xcconfig = {
|
||||||
|
|||||||
Reference in New Issue
Block a user