mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-02 17:14:29 +02:00
24 lines
778 B
Swift
24 lines
778 B
Swift
//
|
|
// PlayerHandler.swift
|
|
// App
|
|
//
|
|
// Created by Rasmus Krämer on 11.04.22.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class PlayerHandler {
|
|
private static var player: AudioPlayer?
|
|
private static var session: PlaybackSession?
|
|
|
|
public static func startPlayback(session: PlaybackSession, playWhenReady: Bool) {
|
|
if player != nil {
|
|
player?.destroy()
|
|
player = nil
|
|
}
|
|
|
|
NowPlayingInfo.setSessionMetadata(metadata: NowPlayingMetadata(id: session.id, itemId: session.libraryItemId!, artworkUrl: session.coverPath, title: session.displayTitle ?? "Unknown title", author: session.displayAuthor, series: nil))
|
|
self.session = session
|
|
player = AudioPlayer(playbackSession: session, playWhenReady: playWhenReady)
|
|
}
|
|
}
|