Merge pull request #1703 from 1hitsong/OSD-Item-Navigation
Create method to navigate to Previous/Next items in playlist
This commit is contained in:
commit
0c59c2a629
|
@ -125,6 +125,11 @@ sub playQueue()
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
if nextItemMediaType = "audiobook"
|
||||||
|
CreateAudioPlayerView()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
if nextItemMediaType = "musicvideo"
|
if nextItemMediaType = "musicvideo"
|
||||||
CreateVideoPlayerView()
|
CreateVideoPlayerView()
|
||||||
return
|
return
|
||||||
|
@ -254,6 +259,10 @@ sub setTopStartingPoint(positionTicks)
|
||||||
m.queue[0].startingPoint = positionTicks
|
m.queue[0].startingPoint = positionTicks
|
||||||
end sub
|
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
|
function getItemType(item) as string
|
||||||
if isValid(item) and isValid(item.json) and isValid(item.json.mediatype) and item.json.mediatype <> ""
|
if isValid(item) and isValid(item.json) and isValid(item.json.mediatype) and item.json.mediatype <> ""
|
||||||
return LCase(item.json.mediatype)
|
return LCase(item.json.mediatype)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<function name="getHold" />
|
<function name="getHold" />
|
||||||
<function name="getIsShuffled" />
|
<function name="getIsShuffled" />
|
||||||
<function name="getItemByIndex" />
|
<function name="getItemByIndex" />
|
||||||
|
<function name="getItemType" />
|
||||||
<function name="getPosition" />
|
<function name="getPosition" />
|
||||||
<function name="getQueue" />
|
<function name="getQueue" />
|
||||||
<function name="getQueueTypes" />
|
<function name="getQueueTypes" />
|
||||||
|
|
|
@ -9,6 +9,8 @@ sub init()
|
||||||
m.lastRecordedPositionTimestamp = 0
|
m.lastRecordedPositionTimestamp = 0
|
||||||
m.scrubTimestamp = -1
|
m.scrubTimestamp = -1
|
||||||
|
|
||||||
|
m.playlistTypeCount = m.global.queueManager.callFunc("getQueueUniqueTypes").count()
|
||||||
|
|
||||||
setupAudioNode()
|
setupAudioNode()
|
||||||
setupAnimationTasks()
|
setupAnimationTasks()
|
||||||
setupButtons()
|
setupButtons()
|
||||||
|
@ -16,8 +18,6 @@ sub init()
|
||||||
setupDataTasks()
|
setupDataTasks()
|
||||||
setupScreenSaver()
|
setupScreenSaver()
|
||||||
|
|
||||||
m.playlistTypeCount = m.global.queueManager.callFunc("getQueueUniqueTypes").count()
|
|
||||||
|
|
||||||
m.buttonCount = m.buttons.getChildCount()
|
m.buttonCount = m.buttons.getChildCount()
|
||||||
m.seekPosition.translation = [720 - (m.seekPosition.width / 2), m.seekPosition.translation[1]]
|
m.seekPosition.translation = [720 - (m.seekPosition.width / 2), m.seekPosition.translation[1]]
|
||||||
|
|
||||||
|
@ -102,6 +102,20 @@ end sub
|
||||||
sub setupButtons()
|
sub setupButtons()
|
||||||
m.buttons = m.top.findNode("buttons")
|
m.buttons = m.top.findNode("buttons")
|
||||||
m.top.observeField("selectedButtonIndex", "onButtonSelectedChange")
|
m.top.observeField("selectedButtonIndex", "onButtonSelectedChange")
|
||||||
|
|
||||||
|
' If we're playing a mixed playlist, remove the shuffle and loop buttons
|
||||||
|
if m.playlistTypeCount > 1
|
||||||
|
shuffleButton = m.top.findNode("shuffle")
|
||||||
|
m.buttons.removeChild(shuffleButton)
|
||||||
|
|
||||||
|
loopButton = m.top.findNode("loop")
|
||||||
|
m.buttons.removeChild(loopButton)
|
||||||
|
|
||||||
|
m.previouslySelectedButtonIndex = 0
|
||||||
|
m.top.selectedButtonIndex = 1
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
m.previouslySelectedButtonIndex = 1
|
m.previouslySelectedButtonIndex = 1
|
||||||
m.top.selectedButtonIndex = 2
|
m.top.selectedButtonIndex = 2
|
||||||
end sub
|
end sub
|
||||||
|
@ -284,8 +298,23 @@ function playAction() as boolean
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function previousClicked() as boolean
|
function previousClicked() as boolean
|
||||||
if m.playlistTypeCount > 1 then return false
|
currentQueuePosition = m.global.queueManager.callFunc("getPosition")
|
||||||
if m.global.queueManager.callFunc("getPosition") = 0 then return false
|
|
||||||
|
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")
|
||||||
|
m.global.queueManager.callFunc("moveBack")
|
||||||
|
m.global.queueManager.callFunc("playQueue")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
exitScrubMode()
|
exitScrubMode()
|
||||||
|
|
||||||
|
@ -339,7 +368,23 @@ sub setLoopButtonImage()
|
||||||
end sub
|
end sub
|
||||||
|
|
||||||
function nextClicked() as boolean
|
function nextClicked() as boolean
|
||||||
if m.playlistTypeCount > 1 then return false
|
if m.playlistTypeCount > 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")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
exitScrubMode()
|
exitScrubMode()
|
||||||
|
|
||||||
|
@ -433,9 +478,6 @@ end sub
|
||||||
|
|
||||||
' If we have more and 1 song to play, fade in the next and previous controls
|
' If we have more and 1 song to play, fade in the next and previous controls
|
||||||
sub loadButtons()
|
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
|
if m.global.queueManager.callFunc("getCount") > 1
|
||||||
m.shuffleIndicator.opacity = ".4"
|
m.shuffleIndicator.opacity = ".4"
|
||||||
m.loopIndicator.opacity = ".4"
|
m.loopIndicator.opacity = ".4"
|
||||||
|
|
|
@ -18,8 +18,8 @@ sub init()
|
||||||
m.top.observeField("playbackState", "onPlaybackStateChanged")
|
m.top.observeField("playbackState", "onPlaybackStateChanged")
|
||||||
m.top.observeField("itemTitleText", "onItemTitleTextChanged")
|
m.top.observeField("itemTitleText", "onItemTitleTextChanged")
|
||||||
|
|
||||||
m.defaultButtonIndex = 1
|
m.defaultButtonIndex = 2
|
||||||
m.focusedButtonIndex = 1
|
m.focusedButtonIndex = 2
|
||||||
|
|
||||||
m.videoControls.buttonFocused = m.defaultButtonIndex
|
m.videoControls.buttonFocused = m.defaultButtonIndex
|
||||||
m.optionControls.buttonFocused = m.optionControls.getChildCount() - 1
|
m.optionControls.buttonFocused = m.optionControls.getChildCount() - 1
|
||||||
|
@ -75,7 +75,7 @@ sub resetFocusToDefaultButton()
|
||||||
m.videoControls.setFocus(true)
|
m.videoControls.setFocus(true)
|
||||||
m.focusedButtonIndex = m.defaultButtonIndex
|
m.focusedButtonIndex = m.defaultButtonIndex
|
||||||
m.videoControls.getChild(m.defaultButtonIndex).focus = true
|
m.videoControls.getChild(m.defaultButtonIndex).focus = true
|
||||||
m.videoControls.buttonFocused = 1
|
m.videoControls.buttonFocused = m.defaultButtonIndex
|
||||||
m.optionControls.buttonFocused = m.optionControls.getChildCount() - 1
|
m.optionControls.buttonFocused = m.optionControls.getChildCount() - 1
|
||||||
end sub
|
end sub
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,11 @@
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
|
||||||
<ButtonGroup id="videoControls" itemSpacings="[20]" layoutDirection="horiz" horizAlignment="center" translation="[960,875]">
|
<ButtonGroup id="videoControls" itemSpacings="[20]" layoutDirection="horiz" horizAlignment="center" translation="[960,875]">
|
||||||
|
<IconButton id="itemBack" background="#070707" focusBackground="#00a4dc" padding="35" icon="pkg:/images/icons/itemPrevious.png" height="65" width="100" />
|
||||||
<IconButton id="chapterBack" background="#070707" focusBackground="#00a4dc" padding="16" icon="pkg:/images/icons/previousChapter.png" height="65" width="100" />
|
<IconButton id="chapterBack" background="#070707" focusBackground="#00a4dc" padding="16" icon="pkg:/images/icons/previousChapter.png" height="65" width="100" />
|
||||||
<IconButton id="videoPlayPause" background="#070707" focusBackground="#00a4dc" padding="35" icon="pkg:/images/icons/play.png" height="65" width="100" />
|
<IconButton id="videoPlayPause" background="#070707" focusBackground="#00a4dc" padding="35" icon="pkg:/images/icons/play.png" height="65" width="100" />
|
||||||
<IconButton id="chapterNext" background="#070707" focusBackground="#00a4dc" padding="16" icon="pkg:/images/icons/nextChapter.png" height="65" width="100" />
|
<IconButton id="chapterNext" background="#070707" focusBackground="#00a4dc" padding="16" icon="pkg:/images/icons/nextChapter.png" height="65" width="100" />
|
||||||
|
<IconButton id="itemNext" background="#070707" focusBackground="#00a4dc" padding="35" icon="pkg:/images/icons/itemNext.png" height="65" width="100" />
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
|
||||||
<Rectangle id="progressBarBackground" color="0x00000098" width="1714" height="8" translation="[103,970]">
|
<Rectangle id="progressBarBackground" color="0x00000098" width="1714" height="8" translation="[103,970]">
|
||||||
|
|
|
@ -92,6 +92,35 @@ sub handleChapterSkipAction(action as string)
|
||||||
end if
|
end if
|
||||||
end sub
|
end sub
|
||||||
|
|
||||||
|
' handleItemSkipAction: Handles user command to skip items
|
||||||
|
'
|
||||||
|
' @param {string} action - skip action to take
|
||||||
|
sub handleItemSkipAction(action as string)
|
||||||
|
if action = "itemnext"
|
||||||
|
' If there is something next in the queue, play it
|
||||||
|
if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1
|
||||||
|
m.top.control = "stop"
|
||||||
|
m.global.sceneManager.callFunc("clearPreviousScene")
|
||||||
|
m.global.queueManager.callFunc("moveForward")
|
||||||
|
m.global.queueManager.callFunc("playQueue")
|
||||||
|
end if
|
||||||
|
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
if action = "itemback"
|
||||||
|
' If there is something previous in the queue, play it
|
||||||
|
if m.global.queueManager.callFunc("getPosition") > 0
|
||||||
|
m.top.control = "stop"
|
||||||
|
m.global.sceneManager.callFunc("clearPreviousScene")
|
||||||
|
m.global.queueManager.callFunc("moveBack")
|
||||||
|
m.global.queueManager.callFunc("playQueue")
|
||||||
|
end if
|
||||||
|
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end sub
|
||||||
|
|
||||||
' handleHideAction: Handles action to hide OSD menu
|
' handleHideAction: Handles action to hide OSD menu
|
||||||
'
|
'
|
||||||
' @param {boolean} resume - controls whether or not to resume video playback when sub is called
|
' @param {boolean} resume - controls whether or not to resume video playback when sub is called
|
||||||
|
@ -220,6 +249,11 @@ sub onOSDAction()
|
||||||
handleShowVideoInfoPopupAction()
|
handleShowVideoInfoPopupAction()
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
if action = "itemback" or action = "itemnext"
|
||||||
|
handleItemSkipAction(action)
|
||||||
|
return
|
||||||
|
end if
|
||||||
end sub
|
end sub
|
||||||
|
|
||||||
' Only setup caption items if captions are allowed
|
' Only setup caption items if captions are allowed
|
||||||
|
|
BIN
images/icons/itemNext.png
Normal file
BIN
images/icons/itemNext.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
images/icons/itemPrevious.png
Normal file
BIN
images/icons/itemPrevious.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue
Block a user