Compare commits

...

1 Commits

Author SHA1 Message Date
tanhakabir 27d5ce4f03 fix error 2021-08-16 21:04:23 -07:00
3 changed files with 22 additions and 22 deletions
+1
View File
@@ -239,5 +239,6 @@ class AudioEngine: AudioEngineProtocol {
if let audioModifiers = audioModifiers, audioModifiers.count > 0 {
audioModifiers.forEach { engine.detach($0) }
}
Log.info("invalidated engine for key \(key)")
}
}
+6 -6
View File
@@ -55,10 +55,10 @@ public struct SALockScreenInfo {
Use to add audio to be queued for playback.
*/
public struct SAAudioQueueItem {
var loc: Location
var url: URL
var mediaInfo: SALockScreenInfo?
var bitrate: SAPlayerBitrate
public var loc: Location
public var url: URL
public var mediaInfo: SALockScreenInfo?
public var bitrate: SAPlayerBitrate
/**
Use to add audio to be queued for playback.
@@ -68,7 +68,7 @@ public struct SAAudioQueueItem {
- Parameter mediaInfo: Relevant lockscreen media info for the queued audio.
- Parameter bitrate: For streamed remote audio specifiy a bitrate if different from high. Use low bitrate for radio streams.
*/
init(loc: Location, url: URL, mediaInfo: SALockScreenInfo?, bitrate: SAPlayerBitrate = .high) {
public init(loc: Location, url: URL, mediaInfo: SALockScreenInfo?, bitrate: SAPlayerBitrate = .high) {
self.loc = loc
self.url = url
self.mediaInfo = mediaInfo
@@ -78,7 +78,7 @@ public struct SAAudioQueueItem {
/**
Where the queued audio is sourced. Remote to be streamed or locally saved on device.
*/
enum Location {
public enum Location {
case remote
case saved
}
+15 -16
View File
@@ -144,13 +144,16 @@ class SAPlayerPresenter {
return
}
self.isPlaying = isPlaying
if(self.isPlaying == .paused && self.shouldPlayImmediately) {
if(isPlaying == .paused && self.shouldPlayImmediately) {
self.shouldPlayImmediately = false
self.handlePlay()
}
// solves bug nil == owningEngine || GetEngine() == owningEngine where too many
// ended statuses were notified to cause 2 engines to be initialized and causes an error.
guard isPlaying != self.isPlaying else { return }
self.isPlaying = isPlaying
if(self.isPlaying == .ended) {
self.playNextAudioIfExists()
}
@@ -246,19 +249,15 @@ extension SAPlayerPresenter {
delegate?.mediaInfo = nextAudioURL.mediaInfo
// We need to give a second to clean up the previous engine properly. Deinit takes some time.
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) { [weak self] (_) in
guard let self = self else { return }
switch nextAudioURL.loc {
case .remote:
self.handlePlayStreamedAudio(withRemoteUrl: nextAudioURL.url, bitrate: nextAudioURL.bitrate)
break
case .saved:
self.handlePlaySavedAudio(withSavedUrl: nextAudioURL.url)
}
self.shouldPlayImmediately = true
switch nextAudioURL.loc {
case .remote:
handlePlayStreamedAudio(withRemoteUrl: nextAudioURL.url, bitrate: nextAudioURL.bitrate)
break
case .saved:
handlePlaySavedAudio(withSavedUrl: nextAudioURL.url)
break
}
shouldPlayImmediately = true
}
}