diff --git a/components/manager/QueueManager.bs b/components/manager/QueueManager.bs index 60bf2426e..1a244ebd7 100644 --- a/components/manager/QueueManager.bs +++ b/components/manager/QueueManager.bs @@ -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) diff --git a/components/manager/QueueManager.xml b/components/manager/QueueManager.xml index f275e49b2..5bdddef74 100644 --- a/components/manager/QueueManager.xml +++ b/components/manager/QueueManager.xml @@ -9,6 +9,7 @@ + diff --git a/components/music/AudioPlayerView.bs b/components/music/AudioPlayerView.bs index 5c78f508d..12786a6bb 100644 --- a/components/music/AudioPlayerView.bs +++ b/components/music/AudioPlayerView.bs @@ -298,15 +298,22 @@ 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 - m.global.audioPlayer.control = "stop" + previousItem = m.global.queueManager.callFunc("getItemByIndex", currentQueuePosition - 1) + previousItemType = m.global.queueManager.callFunc("getItemType", previousItem) - m.global.sceneManager.callFunc("clearPreviousScene") - m.global.queueManager.callFunc("moveBack") - m.global.queueManager.callFunc("playQueue") - return true + if previousItemType <> "audio" + m.global.audioPlayer.control = "stop" + + m.global.sceneManager.callFunc("clearPreviousScene") + m.global.queueManager.callFunc("moveBack") + m.global.queueManager.callFunc("playQueue") + return true + end if end if exitScrubMode() @@ -362,14 +369,21 @@ end sub function nextClicked() as boolean if m.playlistTypeCount > 1 - if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1 - m.global.audioPlayer.control = "stop" + currentQueuePosition = m.global.queueManager.callFunc("getPosition") + if currentQueuePosition < m.global.queueManager.callFunc("getCount") - 1 - m.global.sceneManager.callFunc("clearPreviousScene") - m.global.queueManager.callFunc("moveForward") - m.global.queueManager.callFunc("playQueue") + 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") + return true + end if end if - return true end if exitScrubMode()