1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00
persephone/Persephone/MPDClientNotificationHandler.swift

35 lines
870 B
Swift

//
// MPDClientNotificationHandler.swift
// Persephone
//
// Created by Daniel Barber on 2019/2/02.
// Copyright © 2019 Dan Barber. All rights reserved.
//
import Foundation
import mpdclient
class MPDClientNotificationHandler: MPDClientDelegate {
let notificationQueue = DispatchQueue.main
func didUpdateState(mpdClient: MPDClient, state: mpd_state) {
self.notificationQueue.async {
NotificationCenter.default.post(
name: MPDClient.stateChanged,
object: AppDelegate.mpdClient,
userInfo: [MPDClient.stateKey: state]
)
}
}
func didUpdateQueue(mpdClient: MPDClient, queue: [MPDClient.Song]) {
self.notificationQueue.async {
NotificationCenter.default.post(
name: MPDClient.queueChanged,
object: AppDelegate.mpdClient,
userInfo: [MPDClient.queueKey: queue]
)
}
}
}