mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-05 02:25:45 +02:00
added removeServerConnectionConfig method
This commit is contained in:
parent
363bfd206c
commit
03c3f37e1e
5 changed files with 35 additions and 12 deletions
|
@ -57,7 +57,6 @@ class AudioPlayer: NSObject {
|
|||
playerItem.addObserver(self, forKeyPath: #keyPath(AVPlayerItem.status), options: .new, context: &playerItemContext)
|
||||
|
||||
self.audioPlayer.replaceCurrentItem(with: playerItem)
|
||||
seek(playbackSession.currentTime)
|
||||
|
||||
NSLog("Audioplayer ready")
|
||||
}
|
||||
|
@ -259,6 +258,8 @@ class AudioPlayer: NSObject {
|
|||
self.playWhenReady = false
|
||||
self.play()
|
||||
}
|
||||
|
||||
seek(playbackSession.currentTime)
|
||||
}
|
||||
}
|
||||
} else if context == &playerContext {
|
||||
|
|
|
@ -12,7 +12,7 @@ class PlayerHandler {
|
|||
private static var session: PlaybackSession?
|
||||
private static var timer: Timer?
|
||||
|
||||
private static var listningTimePassedSinceLastSync = 0.0
|
||||
private static var listeningTimePassedSinceLastSync = 0.0
|
||||
|
||||
public static func startPlayback(session: PlaybackSession, playWhenReady: Bool) {
|
||||
if player != nil {
|
||||
|
@ -26,9 +26,9 @@ class PlayerHandler {
|
|||
player = AudioPlayer(playbackSession: session, playWhenReady: playWhenReady)
|
||||
|
||||
// DispatchQueue.main.sync {
|
||||
timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
|
||||
self.tick()
|
||||
}
|
||||
timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
|
||||
self.tick()
|
||||
}
|
||||
// }
|
||||
}
|
||||
public static func stopPlayback() {
|
||||
|
@ -101,10 +101,10 @@ class PlayerHandler {
|
|||
|
||||
private static func tick() {
|
||||
if !paused() {
|
||||
listningTimePassedSinceLastSync += 1
|
||||
listeningTimePassedSinceLastSync += 1
|
||||
}
|
||||
|
||||
if listningTimePassedSinceLastSync > 3 {
|
||||
if listeningTimePassedSinceLastSync > 3 {
|
||||
syncProgress()
|
||||
}
|
||||
}
|
||||
|
@ -113,10 +113,10 @@ class PlayerHandler {
|
|||
return
|
||||
}
|
||||
|
||||
let report = PlaybackReport(currentTime: player!.getCurrentTime(), duration: player!.getDuration(), timeListened: listningTimePassedSinceLastSync)
|
||||
let report = PlaybackReport(currentTime: player!.getCurrentTime(), duration: player!.getDuration(), timeListened: listeningTimePassedSinceLastSync)
|
||||
|
||||
session!.currentTime = player!.getCurrentTime()
|
||||
listningTimePassedSinceLastSync = 0
|
||||
listeningTimePassedSinceLastSync = 0
|
||||
|
||||
// TODO: check if online
|
||||
NSLog("sending playback report")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue