Don't load song data until stream is loaded

Fixes #1609
This commit is contained in:
1hitsong 2024-01-12 21:07:36 -05:00
parent 5aa26f39aa
commit 8bf164ba29

View File

@ -388,6 +388,33 @@ end sub
' Update values on screen when page content changes
sub pageContentChanged()
m.LoadAudioStreamTask.control = "STOP"
currentItem = m.global.queueManager.callFunc("getCurrentItem")
m.LoadAudioStreamTask.itemId = currentItem.id
m.LoadAudioStreamTask.observeField("content", "onAudioStreamLoaded")
m.LoadAudioStreamTask.control = "RUN"
end sub
' If we have more and 1 song to play, fade in the next and previous controls
sub loadButtons()
' Don't show audio buttons if we have a mixed playlist
if m.playlistTypeCount > 1 then return
if m.global.queueManager.callFunc("getCount") > 1
m.shuffleIndicator.opacity = ".4"
m.loopIndicator.opacity = ".4"
m.displayButtonsAnimation.control = "start"
setLoopButtonImage()
end if
end sub
sub onAudioStreamLoaded()
stopLoadingSpinner()
data = m.LoadAudioStreamTask.content[0]
m.LoadAudioStreamTask.unobserveField("content")
if data <> invalid and data.count() > 0
' Reset buffer bar without animation
m.bufferPosition.width = 0
@ -428,29 +455,6 @@ sub pageContentChanged()
m.totalLengthTimestamp.text = ticksToHuman(currentItem.RunTimeTicks)
end if
m.LoadAudioStreamTask.itemId = currentItem.id
m.LoadAudioStreamTask.observeField("content", "onAudioStreamLoaded")
m.LoadAudioStreamTask.control = "RUN"
end sub
' If we have more and 1 song to play, fade in the next and previous controls
sub loadButtons()
' Don't show audio buttons if we have a mixed playlist
if m.playlistTypeCount > 1 then return
if m.global.queueManager.callFunc("getCount") > 1
m.shuffleIndicator.opacity = ".4"
m.loopIndicator.opacity = ".4"
m.displayButtonsAnimation.control = "start"
setLoopButtonImage()
end if
end sub
sub onAudioStreamLoaded()
stopLoadingSpinner()
data = m.LoadAudioStreamTask.content[0]
m.LoadAudioStreamTask.unobserveField("content")
if data <> invalid and data.count() > 0
m.global.audioPlayer.content = data
m.global.audioPlayer.control = "none"
m.global.audioPlayer.control = "play"