If current and next item are both audio, don't leave player

This commit is contained in:
1hitsong 2024-02-22 19:26:35 -05:00
parent d9f714690e
commit 39abf06056
3 changed files with 31 additions and 12 deletions

View File

@ -259,6 +259,10 @@ sub setTopStartingPoint(positionTicks)
m.queue[0].startingPoint = positionTicks
end sub
' getItemType: Returns the media type of the passed item
'
' @param {dynamic} item - Item to evaluate
' @return {string} indicating type of media item is
function getItemType(item) as string
if isValid(item) and isValid(item.json) and isValid(item.json.mediatype) and item.json.mediatype <> ""
return LCase(item.json.mediatype)

View File

@ -9,6 +9,7 @@
<function name="getHold" />
<function name="getIsShuffled" />
<function name="getItemByIndex" />
<function name="getItemType" />
<function name="getPosition" />
<function name="getQueue" />
<function name="getQueueTypes" />

View File

@ -298,9 +298,15 @@ function playAction() as boolean
end function
function previousClicked() as boolean
if m.global.queueManager.callFunc("getPosition") = 0 then return false
currentQueuePosition = m.global.queueManager.callFunc("getPosition")
if currentQueuePosition = 0 then return false
if m.playlistTypeCount > 1
previousItem = m.global.queueManager.callFunc("getItemByIndex", currentQueuePosition - 1)
previousItemType = m.global.queueManager.callFunc("getItemType", previousItem)
if previousItemType <> "audio"
m.global.audioPlayer.control = "stop"
m.global.sceneManager.callFunc("clearPreviousScene")
@ -308,6 +314,7 @@ function previousClicked() as boolean
m.global.queueManager.callFunc("playQueue")
return true
end if
end if
exitScrubMode()
@ -362,15 +369,22 @@ end sub
function nextClicked() as boolean
if m.playlistTypeCount > 1
if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1
currentQueuePosition = m.global.queueManager.callFunc("getPosition")
if currentQueuePosition < m.global.queueManager.callFunc("getCount") - 1
nextItem = m.global.queueManager.callFunc("getItemByIndex", currentQueuePosition + 1)
nextItemType = m.global.queueManager.callFunc("getItemType", nextItem)
if nextItemType <> "audio"
m.global.audioPlayer.control = "stop"
m.global.sceneManager.callFunc("clearPreviousScene")
m.global.queueManager.callFunc("moveForward")
m.global.queueManager.callFunc("playQueue")
end if
return true
end if
end if
end if
exitScrubMode()