diff options
author | der richter <der.richter@gmx.de> | 2024-02-09 21:00:37 +0100 |
---|---|---|
committer | der richter <der.richter@gmx.de> | 2024-02-15 00:11:55 +0100 |
commit | ca8c61838eb30fb7c3253ff395483912b2da3c30 (patch) | |
tree | 6ccc7be76926879db491a48e1551bdceea19ab82 | |
parent | 0a343369bad108e7a2267345adb71aa8687a4ddb (diff) | |
download | mpv-ca8c61838eb30fb7c3253ff395483912b2da3c30.tar.bz2 mpv-ca8c61838eb30fb7c3253ff395483912b2da3c30.tar.xz |
mac/remote: add media-title info
Fixes #11233
-rw-r--r-- | osdep/macos/remote_command_center.swift | 9 | ||||
-rw-r--r-- | osdep/macosx_events.m | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/osdep/macos/remote_command_center.swift b/osdep/macos/remote_command_center.swift index 4eb112d936..8eb2c1dda2 100644 --- a/osdep/macos/remote_command_center.swift +++ b/osdep/macos/remote_command_center.swift @@ -47,6 +47,7 @@ class RemoteCommandCenter: NSObject { var duration: Double = 0 { didSet { updateInfoCenter() } } var position: Double = 0 { didSet { updateInfoCenter() } } var rate: Double = 0 { didSet { updateInfoCenter() } } + var title: String = "" { didSet { updateInfoCenter() } } var infoCenter: MPNowPlayingInfoCenter { get { return MPNowPlayingInfoCenter.default() } } var commandCenter: MPRemoteCommandCenter { get { return MPRemoteCommandCenter.shared() } } @@ -57,9 +58,8 @@ class RemoteCommandCenter: NSObject { nowPlayingInfo = [ MPNowPlayingInfoPropertyMediaType: NSNumber(value: MPNowPlayingInfoMediaType.video.rawValue), MPNowPlayingInfoPropertyPlaybackProgress: NSNumber(value: 0.0), - MPMediaItemPropertyTitle: "mpv", - MPMediaItemPropertyAlbumTitle: "mpv", - MPMediaItemPropertyArtist: "mpv", + MPMediaItemPropertyAlbumTitle: "", + MPMediaItemPropertyArtist: "", ] configs = [ @@ -143,6 +143,7 @@ class RemoteCommandCenter: NSObject { MPNowPlayingInfoPropertyPlaybackRate: NSNumber(value: isPaused ? 0 : rate), MPNowPlayingInfoPropertyElapsedPlaybackTime: NSNumber(value: position), MPMediaItemPropertyPlaybackDuration: NSNumber(value: duration), + MPMediaItemPropertyTitle: title, ]) { (_, new) in new } infoCenter.nowPlayingInfo = nowPlayingInfo @@ -192,6 +193,8 @@ class RemoteCommandCenter: NSObject { duration = LibmpvHelper.mpvDoubleToDouble(property.data) ?? 0 case "speed" where property.format == MPV_FORMAT_DOUBLE: rate = LibmpvHelper.mpvDoubleToDouble(property.data) ?? 1 + case "media-title" where [MPV_FORMAT_STRING, MPV_FORMAT_NONE].contains(property.format): + title = LibmpvHelper.mpvStringArrayToString(property.data) ?? "" default: break } diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m index 6ffff3d161..8722528bc7 100644 --- a/osdep/macosx_events.m +++ b/osdep/macosx_events.m @@ -158,6 +158,7 @@ void cocoa_set_mpv_handle(struct mpv_handle *ctx) mpv_observe_property(ctx, 0, "time-pos", MPV_FORMAT_DOUBLE); mpv_observe_property(ctx, 0, "speed", MPV_FORMAT_DOUBLE); mpv_observe_property(ctx, 0, "pause", MPV_FORMAT_FLAG); + mpv_observe_property(ctx, 0, "media-title", MPV_FORMAT_STRING); mpv_set_wakeup_callback(ctx, wakeup, NULL); } } |