mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Compare commits
5 Commits
a52ba06a08
...
89b26c4b8a
| Author | SHA1 | Date | |
|---|---|---|---|
| 89b26c4b8a | |||
| 3c9a18a9fe | |||
| b98d7a4f93 | |||
| 4094fc19ea | |||
| e441d7b0d6 |
@ -42,6 +42,7 @@
|
|||||||
E42A8F3C22176D6400A13ED9 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = E42A8F3A22176D6400A13ED9 /* README.md */; };
|
E42A8F3C22176D6400A13ED9 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = E42A8F3A22176D6400A13ED9 /* README.md */; };
|
||||||
E435E3E2221CD4E200184CFC /* NSFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = E435E3E1221CD4E200184CFC /* NSFont.swift */; };
|
E435E3E2221CD4E200184CFC /* NSFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = E435E3E1221CD4E200184CFC /* NSFont.swift */; };
|
||||||
E435E3E4221CD75D00184CFC /* NSImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = E435E3E3221CD75D00184CFC /* NSImage.swift */; };
|
E435E3E4221CD75D00184CFC /* NSImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = E435E3E3221CD75D00184CFC /* NSImage.swift */; };
|
||||||
|
E439109822640213002982E9 /* SongNotifierService.swift in Sources */ = {isa = PBXBuildFile; fileRef = E439109722640213002982E9 /* SongNotifierService.swift */; };
|
||||||
E450AD7E222620A10091BED3 /* Album.swift in Sources */ = {isa = PBXBuildFile; fileRef = E450AD7D222620A10091BED3 /* Album.swift */; };
|
E450AD7E222620A10091BED3 /* Album.swift in Sources */ = {isa = PBXBuildFile; fileRef = E450AD7D222620A10091BED3 /* Album.swift */; };
|
||||||
E450AD8622262AE60091BED3 /* SwiftyJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E450AD8522262AE60091BED3 /* SwiftyJSON.framework */; };
|
E450AD8622262AE60091BED3 /* SwiftyJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E450AD8522262AE60091BED3 /* SwiftyJSON.framework */; };
|
||||||
E450AD8822262AEC0091BED3 /* SwiftyJSON.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = E450AD8522262AE60091BED3 /* SwiftyJSON.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
E450AD8822262AEC0091BED3 /* SwiftyJSON.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = E450AD8522262AE60091BED3 /* SwiftyJSON.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
@ -210,6 +211,7 @@
|
|||||||
E42A8F3A22176D6400A13ED9 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
E42A8F3A22176D6400A13ED9 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||||
E435E3E1221CD4E200184CFC /* NSFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSFont.swift; sourceTree = "<group>"; };
|
E435E3E1221CD4E200184CFC /* NSFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSFont.swift; sourceTree = "<group>"; };
|
||||||
E435E3E3221CD75D00184CFC /* NSImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSImage.swift; sourceTree = "<group>"; };
|
E435E3E3221CD75D00184CFC /* NSImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSImage.swift; sourceTree = "<group>"; };
|
||||||
|
E439109722640213002982E9 /* SongNotifierService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SongNotifierService.swift; sourceTree = "<group>"; };
|
||||||
E450AD7D222620A10091BED3 /* Album.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Album.swift; sourceTree = "<group>"; };
|
E450AD7D222620A10091BED3 /* Album.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Album.swift; sourceTree = "<group>"; };
|
||||||
E450AD8522262AE60091BED3 /* SwiftyJSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyJSON.framework; path = Carthage/Build/Mac/SwiftyJSON.framework; sourceTree = "<group>"; };
|
E450AD8522262AE60091BED3 /* SwiftyJSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyJSON.framework; path = Carthage/Build/Mac/SwiftyJSON.framework; sourceTree = "<group>"; };
|
||||||
E450AD8C22262C590091BED3 /* PromiseKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PromiseKit.framework; path = Carthage/Build/Mac/PromiseKit.framework; sourceTree = "<group>"; };
|
E450AD8C22262C590091BED3 /* PromiseKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PromiseKit.framework; path = Carthage/Build/Mac/PromiseKit.framework; sourceTree = "<group>"; };
|
||||||
@ -523,6 +525,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
E4A83BF3222207D50098FED6 /* AlbumArtService.swift */,
|
E4A83BF3222207D50098FED6 /* AlbumArtService.swift */,
|
||||||
|
E439109722640213002982E9 /* SongNotifierService.swift */,
|
||||||
E41E530C223EF4BA00173814 /* Extensions */,
|
E41E530C223EF4BA00173814 /* Extensions */,
|
||||||
);
|
);
|
||||||
path = Services;
|
path = Services;
|
||||||
@ -797,6 +800,7 @@
|
|||||||
E40F41F3221EDE27004B6CB8 /* Preferences.swift in Sources */,
|
E40F41F3221EDE27004B6CB8 /* Preferences.swift in Sources */,
|
||||||
E47E2FDD2220A6D100F747E6 /* Time.swift in Sources */,
|
E47E2FDD2220A6D100F747E6 /* Time.swift in Sources */,
|
||||||
E419E2872249B96600216A8C /* Song.swift in Sources */,
|
E419E2872249B96600216A8C /* Song.swift in Sources */,
|
||||||
|
E439109822640213002982E9 /* SongNotifierService.swift in Sources */,
|
||||||
E407861C2110CE6E006887B1 /* AppDelegate.swift in Sources */,
|
E407861C2110CE6E006887B1 /* AppDelegate.swift in Sources */,
|
||||||
E41E5309223C020400173814 /* MPDClient+Command.swift in Sources */,
|
E41E5309223C020400173814 /* MPDClient+Command.swift in Sources */,
|
||||||
E47E2FE52220AA0700F747E6 /* AlbumViewLayout.swift in Sources */,
|
E47E2FE52220AA0700F747E6 /* AlbumViewLayout.swift in Sources */,
|
||||||
|
|||||||
@ -49,6 +49,16 @@ class QueueViewController: NSViewController,
|
|||||||
dataSource.setQueueIcon(state)
|
dataSource.setQueueIcon(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func notifyTrack() {
|
||||||
|
guard let currentSong = dataSource.currentSong,
|
||||||
|
let status = AppDelegate.mpdClient.status,
|
||||||
|
status.state == .playing
|
||||||
|
else { return }
|
||||||
|
|
||||||
|
SongNotifierService(song: currentSong, image: queueAlbumArtImage.image)
|
||||||
|
.deliver()
|
||||||
|
}
|
||||||
|
|
||||||
@objc func queueChanged(_ notification: Notification) {
|
@objc func queueChanged(_ notification: Notification) {
|
||||||
guard let queue = notification.userInfo?[Notification.queueKey] as? [MPDClient.MPDSong]
|
guard let queue = notification.userInfo?[Notification.queueKey] as? [MPDClient.MPDSong]
|
||||||
else { return }
|
else { return }
|
||||||
@ -77,6 +87,8 @@ class QueueViewController: NSViewController,
|
|||||||
} else {
|
} else {
|
||||||
self.queueAlbumArtImage.image = NSImage.defaultCoverArt
|
self.queueAlbumArtImage.image = NSImage.defaultCoverArt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.notifyTrack()
|
||||||
}
|
}
|
||||||
.cauterize()
|
.cauterize()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import Cocoa
|
|||||||
class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
||||||
var queue: [QueueItem] = []
|
var queue: [QueueItem] = []
|
||||||
var queuePos: Int = -1
|
var queuePos: Int = -1
|
||||||
|
var currentSong: Song?
|
||||||
|
|
||||||
var queueIcon: NSImage? = nil
|
var queueIcon: NSImage? = nil
|
||||||
|
|
||||||
@ -37,6 +38,9 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
|||||||
}
|
}
|
||||||
if newSongRowPos >= 0 {
|
if newSongRowPos >= 0 {
|
||||||
queue[newSongRowPos].isPlaying = true
|
queue[newSongRowPos].isPlaying = true
|
||||||
|
currentSong = queue[newSongRowPos].song
|
||||||
|
} else {
|
||||||
|
currentSong = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,9 +43,9 @@ extension MPDClient {
|
|||||||
self.fetchStatus()
|
self.fetchStatus()
|
||||||
|
|
||||||
if let status = self.status {
|
if let status = self.status {
|
||||||
|
self.delegate?.didUpdateQueuePos(mpdClient: self, song: status.song)
|
||||||
self.delegate?.didUpdateState(mpdClient: self, state: status.state)
|
self.delegate?.didUpdateState(mpdClient: self, state: status.state)
|
||||||
self.delegate?.didUpdateTime(mpdClient: self, total: status.totalTime, elapsedMs: status.elapsedTimeMs)
|
self.delegate?.didUpdateTime(mpdClient: self, total: status.totalTime, elapsedMs: status.elapsedTimeMs)
|
||||||
self.delegate?.didUpdateQueuePos(mpdClient: self, song: status.song)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if mpdIdle.contains(.update) {
|
if mpdIdle.contains(.update) {
|
||||||
|
|||||||
23
Persephone/Services/SongNotifierService.swift
Normal file
23
Persephone/Services/SongNotifierService.swift
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// SongNotifierService.swift
|
||||||
|
// Persephone
|
||||||
|
//
|
||||||
|
// Created by Daniel Barber on 2019/4/14.
|
||||||
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Cocoa
|
||||||
|
|
||||||
|
struct SongNotifierService {
|
||||||
|
let song: Song
|
||||||
|
let image: NSImage?
|
||||||
|
|
||||||
|
func deliver() {
|
||||||
|
let notification = NSUserNotification()
|
||||||
|
notification.title = song.title
|
||||||
|
notification.subtitle = "\(song.artist) — \(song.album.title)"
|
||||||
|
notification.contentImage = image
|
||||||
|
|
||||||
|
NSUserNotificationCenter.default.deliver(notification)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user