mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Use Kingfisher to fetch the notification album art
This commit is contained in:
parent
4322a25b8b
commit
b712a8d00d
@ -8,8 +8,11 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
import Kingfisher
|
||||||
|
|
||||||
class UserNotificationsController {
|
class UserNotificationsController {
|
||||||
|
let cache = ImageCache.default
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
App.store.subscribe(self) {
|
App.store.subscribe(self) {
|
||||||
$0.select { $0.playerState.currentSong }
|
$0.select { $0.playerState.currentSong }
|
||||||
@ -18,18 +21,28 @@ class UserNotificationsController {
|
|||||||
|
|
||||||
func notifyTrack(_ state: Song?) {
|
func notifyTrack(_ state: Song?) {
|
||||||
guard let currentSong = state,
|
guard let currentSong = state,
|
||||||
|
let coverArtFilePath = currentSong.album.coverArtFilePath,
|
||||||
let status = App.mpdClient.status,
|
let status = App.mpdClient.status,
|
||||||
status.state == .playing
|
status.state == .playing
|
||||||
else { return }
|
else { return }
|
||||||
//
|
|
||||||
// let coverArtService = CoverArtService(path: currentSong.mpdSong.path, album: currentSong.album)
|
let imageURL = URL(fileURLWithPath: coverArtFilePath)
|
||||||
//
|
let provider = LocalFileImageDataProvider(fileURL: imageURL)
|
||||||
// coverArtService.fetchBigCoverArt()
|
_ = KingfisherManager.shared.retrieveImage(
|
||||||
// .done() {
|
with: .provider(provider),
|
||||||
// SongNotifierService(song: currentSong, image: $0)
|
options: [
|
||||||
// .deliver()
|
.processor(DownsamplingImageProcessor(size: NSSize(width: 180, height: 180))),
|
||||||
// }
|
.scaleFactor(2),
|
||||||
// .cauterize()
|
]
|
||||||
|
) { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let value):
|
||||||
|
SongNotifierService(song: currentSong, image: value.image)
|
||||||
|
.deliver()
|
||||||
|
case .failure:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,6 @@
|
|||||||
import AppKit
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
struct UpdateCurrentCoverArtAction: Action {
|
|
||||||
var coverArt: NSImage?
|
|
||||||
}
|
|
||||||
|
|
||||||
struct UpdateCurrentSongAction: Action {
|
struct UpdateCurrentSongAction: Action {
|
||||||
var currentSong: Song?
|
var currentSong: Song?
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,9 +39,6 @@ func playerReducer(action: Action, state: PlayerState?) -> PlayerState {
|
|||||||
case let action as UpdateCurrentSongAction:
|
case let action as UpdateCurrentSongAction:
|
||||||
state.currentSong = action.currentSong
|
state.currentSong = action.currentSong
|
||||||
|
|
||||||
case let action as UpdateCurrentCoverArtAction:
|
|
||||||
break
|
|
||||||
|
|
||||||
case let action as UpdateElapsedTimeAction:
|
case let action as UpdateElapsedTimeAction:
|
||||||
state.elapsedTimeMs = action.elapsedTimeMs
|
state.elapsedTimeMs = action.elapsedTimeMs
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user