mirror of
https://github.com/yattee/yattee.git
synced 2024-12-24 14:33:40 +00:00
Fix EOF handler
This commit is contained in:
parent
76857e5eb6
commit
d45175e67b
@ -271,11 +271,9 @@ final class MPVBackend: PlayerBackend {
|
|||||||
onFileLoaded = nil
|
onFileLoaded = nil
|
||||||
|
|
||||||
case MPV_EVENT_END_FILE:
|
case MPV_EVENT_END_FILE:
|
||||||
break
|
DispatchQueue.main.async { [weak self] in
|
||||||
// DispatchQueue.main.async { [weak self] in
|
self?.handleEndOfFile(event)
|
||||||
// TODO: handle EOF
|
}
|
||||||
// self?.handleEndOfFile(event)
|
|
||||||
// }
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logger.info(.init(stringLiteral: "event: \(String(cString: mpv_event_name(event.pointee.event_id)))"))
|
logger.info(.init(stringLiteral: "event: \(String(cString: mpv_event_name(event.pointee.event_id)))"))
|
||||||
|
@ -429,11 +429,15 @@ final class PlayerModel: ObservableObject {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
func updateNowPlayingInfo() {
|
func updateNowPlayingInfo() {
|
||||||
|
guard let video = currentItem?.video else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let currentTime = (backend.currentTime?.seconds.isFinite ?? false) ? backend.currentTime!.seconds : 0
|
let currentTime = (backend.currentTime?.seconds.isFinite ?? false) ? backend.currentTime!.seconds : 0
|
||||||
var nowPlayingInfo: [String: AnyObject] = [
|
var nowPlayingInfo: [String: AnyObject] = [
|
||||||
MPMediaItemPropertyTitle: currentItem.video.title as AnyObject,
|
MPMediaItemPropertyTitle: video.title as AnyObject,
|
||||||
MPMediaItemPropertyArtist: currentItem.video.author as AnyObject,
|
MPMediaItemPropertyArtist: video.author as AnyObject,
|
||||||
MPNowPlayingInfoPropertyIsLiveStream: currentItem.video.live as AnyObject,
|
MPNowPlayingInfoPropertyIsLiveStream: video.live as AnyObject,
|
||||||
MPNowPlayingInfoPropertyElapsedPlaybackTime: currentTime as AnyObject,
|
MPNowPlayingInfoPropertyElapsedPlaybackTime: currentTime as AnyObject,
|
||||||
MPNowPlayingInfoPropertyPlaybackQueueCount: queue.count as AnyObject,
|
MPNowPlayingInfoPropertyPlaybackQueueCount: queue.count as AnyObject,
|
||||||
MPNowPlayingInfoPropertyPlaybackQueueIndex: 1 as AnyObject,
|
MPNowPlayingInfoPropertyPlaybackQueueIndex: 1 as AnyObject,
|
||||||
@ -444,7 +448,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
nowPlayingInfo[MPMediaItemPropertyArtwork] = currentArtwork as AnyObject
|
nowPlayingInfo[MPMediaItemPropertyArtwork] = currentArtwork as AnyObject
|
||||||
}
|
}
|
||||||
|
|
||||||
if !currentItem.video.live {
|
if !video.live {
|
||||||
let itemDuration = (backend.playerItemDuration ?? .zero).seconds
|
let itemDuration = (backend.playerItemDuration ?? .zero).seconds
|
||||||
let duration = itemDuration.isFinite ? Double(itemDuration) : nil
|
let duration = itemDuration.isFinite ? Double(itemDuration) : nil
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ struct VideoPlayerView: View {
|
|||||||
Color.clear
|
Color.clear
|
||||||
.onAppear {
|
.onAppear {
|
||||||
player.playerSize = proxy.size
|
player.playerSize = proxy.size
|
||||||
// TODO move to backend method
|
// TODO: move to backend method
|
||||||
player.mpvBackend.client?.setSize(proxy.size.width, proxy.size.height)
|
player.mpvBackend.client?.setSize(proxy.size.width, proxy.size.height)
|
||||||
}
|
}
|
||||||
.onChange(of: proxy.size) { _ in
|
.onChange(of: proxy.size) { _ in
|
||||||
|
Loading…
Reference in New Issue
Block a user