Skip to content

Commit

Permalink
Much faster handling of unavailable tracks.
Browse files Browse the repository at this point in the history
  • Loading branch information
melgu committed Jun 12, 2020
1 parent 96a1890 commit e70f794
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions TidalSwift/Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,30 @@ class Player {
let wasPlaying = playbackInfo.playing
pause()

func skip() {
failedItems += 1
if failedItems == queueInfo.queue.count {
clearQueue()
} else {
next()
}
}

if track.isUnavailable {
skip()
return
}

let url: URL
if let offlineUrl = session.helpers.offline.url(for: track) {
url = offlineUrl
} else {
guard let onlineUrl = track.getAudioUrl(session: session) else {
failedItems += 1
if failedItems == queueInfo.queue.count {
clearQueue()
} else {
next()
}
if let onlineUrl = track.getAudioUrl(session: session) {
url = onlineUrl
} else {
skip()
return
}
url = onlineUrl
}
failedItems = 0

Expand Down

0 comments on commit e70f794

Please sign in to comment.