mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-12 00:40:23 +01:00
Go back to vlc4
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'VlcPlayer'
|
||||
s.version = '4.0.0a10'
|
||||
s.version = '4.0.0a13'
|
||||
s.summary = 'A sample project summary'
|
||||
s.description = 'A sample project description'
|
||||
s.author = ''
|
||||
|
||||
@@ -68,4 +68,4 @@ public class VlcPlayerModule: Module {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,6 +118,7 @@ extension VLCPlayerWrapper: VLCMediaPlayerDelegate {
|
||||
func mediaPlayerTimeChanged(_ aNotification: Notification) {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.performInitialSeek()
|
||||
let timeNow = Date().timeIntervalSince1970
|
||||
if timeNow - self.lastProgressCall >= 1 {
|
||||
self.lastProgressCall = timeNow
|
||||
@@ -135,11 +136,22 @@ extension VLCPlayerWrapper: VLCMediaPlayerDelegate {
|
||||
pipController.invalidatePlaybackState()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - VLCMediaDelegate
|
||||
extension VLCPlayerWrapper: VLCMediaDelegate {
|
||||
// Implement VLCMediaDelegate methods if needed
|
||||
// Workaround: When playing an HLS video for the first time, seeking to a specific time immediately can cause a crash.
|
||||
// To avoid this, we wait until the video has started playing before performing the initial seek.
|
||||
func performInitialSeek() {
|
||||
guard let vlcPlayerView = self.playerView.superview as? VlcPlayerView,
|
||||
!vlcPlayerView.initialSeekPerformed,
|
||||
vlcPlayerView.startPosition > 0,
|
||||
vlcPlayerView.isTranscoding,
|
||||
player.isSeekable else { return }
|
||||
vlcPlayerView.initialSeekPerformed = true
|
||||
// Use a logger from the VlcPlayerView if available, or create a new one
|
||||
let logger = (vlcPlayerView).logger
|
||||
logger.debug("First time update, performing initial seek to \(vlcPlayerView.startPosition) seconds")
|
||||
player.time = VLCTime(int: vlcPlayerView.startPosition * 1000)
|
||||
self.updateVideoProgress?()
|
||||
}
|
||||
}
|
||||
|
||||
class VlcPlayerView: ExpoView {
|
||||
@@ -149,11 +161,13 @@ class VlcPlayerView: ExpoView {
|
||||
private var progressUpdateInterval: TimeInterval = 1.0 // Update interval set to 1 second
|
||||
private var isPaused: Bool = false
|
||||
private var customSubtitles: [(internalName: String, originalName: String)] = []
|
||||
private var startPosition: Int32 = 0
|
||||
var startPosition: Int32 = 0
|
||||
private var externalTrack: [String: String]?
|
||||
private var isStopping: Bool = false // Define isStopping here
|
||||
private var externalSubtitles: [[String: String]]?
|
||||
var hasSource = false
|
||||
var initialSeekPerformed = false
|
||||
var isTranscoding: Bool = false
|
||||
|
||||
// MARK: - Initialization
|
||||
required init(appContext: AppContext? = nil) {
|
||||
@@ -251,6 +265,9 @@ 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
|
||||
|
||||
@@ -277,8 +294,11 @@ class VlcPlayerView: ExpoView {
|
||||
self.hasSource = true
|
||||
if autoplay {
|
||||
logger.info("Playing...")
|
||||
// The Video is not transcoding so it its safe to seek to the start position.
|
||||
if !self.isTranscoding {
|
||||
self.vlc.player.time = VLCTime(number: NSNumber(value: self.startPosition * 1000))
|
||||
}
|
||||
self.play()
|
||||
self.vlc.player.time = VLCTime(number: NSNumber(value: self.startPosition * 1000))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user