Merge pull request #662 from stonerl/piped-proxy

Conditional proxying
This commit is contained in:
Arkadiusz Fal
2024-05-18 11:42:11 +02:00
committed by GitHub
40 changed files with 544 additions and 125 deletions

View File

@@ -40,6 +40,11 @@ final class AVPlayerBackend: PlayerBackend {
var isLoadingVideo = false
var hasStarted = false
var isPaused: Bool {
avPlayer.timeControlStatus == .paused
}
var isPlaying: Bool {
avPlayer.timeControlStatus == .playing
}
@@ -158,6 +163,12 @@ final class AVPlayerBackend: PlayerBackend {
}
avPlayer.play()
// Setting hasStarted to true the first time player started
if !hasStarted {
hasStarted = true
}
model.objectWillChange.send()
}
@@ -180,6 +191,7 @@ final class AVPlayerBackend: PlayerBackend {
func stop() {
avPlayer.replaceCurrentItem(with: nil)
hasStarted = false
}
func cancelLoads() {

View File

@@ -44,6 +44,8 @@ final class MPVBackend: PlayerBackend {
}
}}
var hasStarted = false
var isPaused = false
var isPlaying = true { didSet {
networkStateTimer.start()
@@ -337,7 +339,6 @@ final class MPVBackend: PlayerBackend {
}
func play() {
isPlaying = true
startClientUpdates()
if controls.presentingControls {
@@ -354,13 +355,22 @@ final class MPVBackend: PlayerBackend {
}
client?.play()
isPlaying = true
isPaused = false
// Setting hasStarted to true the first time player started
if !hasStarted {
hasStarted = true
}
}
func pause() {
isPlaying = false
stopClientUpdates()
client?.pause()
isPaused = true
isPlaying = false
}
func togglePlay() {
@@ -377,6 +387,9 @@ final class MPVBackend: PlayerBackend {
func stop() {
client?.stop()
isPlaying = false
isPaused = false
hasStarted = false
}
func seek(to time: CMTime, seekType _: SeekType, completionHandler: ((Bool) -> Void)?) {
@@ -392,8 +405,8 @@ final class MPVBackend: PlayerBackend {
}
func closeItem() {
client?.pause()
client?.stop()
pause()
stop()
self.video = nil
self.stream = nil
}

View File

@@ -19,6 +19,8 @@ protocol PlayerBackend {
var loadedVideo: Bool { get }
var isLoadingVideo: Bool { get }
var hasStarted: Bool { get }
var isPaused: Bool { get }
var isPlaying: Bool { get }
var isSeeking: Bool { get }
var playerItemDuration: CMTime? { get }