mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
@@ -132,6 +132,8 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
}
|
||||
|
||||
func seek(to time: CMTime, completionHandler: ((Bool) -> Void)?) {
|
||||
guard !model.live else { return }
|
||||
|
||||
avPlayer.seek(
|
||||
to: time,
|
||||
toleranceBefore: .secondsInDefaultTimescale(1),
|
||||
|
@@ -140,6 +140,8 @@ final class MPVClient: ObservableObject {
|
||||
options.append("sub-files-append=\"\(subURL)\"")
|
||||
}
|
||||
|
||||
options.append("force-seekable=yes")
|
||||
|
||||
args.append(options.joined(separator: ","))
|
||||
|
||||
command("loadfile", args: args, returnValueCallback: completionHandler)
|
||||
|
@@ -273,7 +273,7 @@ final class PlayerModel: ObservableObject {
|
||||
}
|
||||
|
||||
var videoDuration: TimeInterval? {
|
||||
currentItem?.duration ?? currentVideo?.length ?? playerItemDuration?.seconds
|
||||
playerItemDuration?.seconds ?? currentItem?.duration ?? currentVideo?.length
|
||||
}
|
||||
|
||||
var time: CMTime? {
|
||||
@@ -284,6 +284,18 @@ final class PlayerModel: ObservableObject {
|
||||
currentVideo?.live ?? false
|
||||
}
|
||||
|
||||
var playingLive: Bool {
|
||||
guard live,
|
||||
let videoDuration = videoDuration,
|
||||
let time = backend.currentTime?.seconds else { return false }
|
||||
|
||||
return videoDuration - time < 30
|
||||
}
|
||||
|
||||
var liveStreamInAVPlayer: Bool {
|
||||
live && activeBackend == .appleAVPlayer
|
||||
}
|
||||
|
||||
func togglePlay() {
|
||||
backend.togglePlay()
|
||||
}
|
||||
@@ -751,7 +763,7 @@ final class PlayerModel: ObservableObject {
|
||||
var nowPlayingInfo: [String: AnyObject] = [
|
||||
MPMediaItemPropertyTitle: video.title as AnyObject,
|
||||
MPMediaItemPropertyArtist: video.author as AnyObject,
|
||||
MPNowPlayingInfoPropertyIsLiveStream: video.live as AnyObject,
|
||||
MPNowPlayingInfoPropertyIsLiveStream: live as AnyObject,
|
||||
MPNowPlayingInfoPropertyElapsedPlaybackTime: currentTime as AnyObject,
|
||||
MPNowPlayingInfoPropertyPlaybackQueueCount: queue.count as AnyObject,
|
||||
MPNowPlayingInfoPropertyPlaybackQueueIndex: 1 as AnyObject,
|
||||
|
Reference in New Issue
Block a user