feat: add milo as now playing album artwork

This commit is contained in:
2024-08-02 13:16:40 +01:00
parent 3c199c2b31
commit 2ea1174216
5 changed files with 35 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Milo0.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Milo0@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Milo0@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@@ -18,6 +18,8 @@ class PlaybackManager: ObservableObject {
private var fadeOutTimer: Timer? private var fadeOutTimer: Timer?
private var scheduledFadeOutTimer: Timer? private var scheduledFadeOutTimer: Timer?
private var miloArtwork = UIImage(named: "Milo0")
init() { init() {
Task { try await initialize() } Task { try await initialize() }
} }
@@ -31,10 +33,18 @@ class PlaybackManager: ObservableObject {
NotificationCenter.default.addObserver(self, selector: #selector(onAudioInterrupted), name: AVAudioSession.interruptionNotification, object: audioSession) NotificationCenter.default.addObserver(self, selector: #selector(onAudioInterrupted), name: AVAudioSession.interruptionNotification, object: audioSession)
MPNowPlayingInfoCenter.default().nowPlayingInfo = [ var nowPlayInfo: [String: Any] = [
MPMediaItemPropertyTitle: "infinite lo-fi music", MPMediaItemPropertyTitle: "infinite lo-fi music",
MPMediaItemPropertyArtist: "infinifi" MPMediaItemPropertyArtist: "infinifi",
MPNowPlayingInfoPropertyIsLiveStream: true,
] ]
if let milo = miloArtwork {
nowPlayInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: milo.size) { _ in
milo
}
}
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayInfo
let cmdCenter = MPRemoteCommandCenter.shared() let cmdCenter = MPRemoteCommandCenter.shared()