2022-11-29 22:05:46 +00:00
|
|
|
sub init()
|
|
|
|
m.queue = []
|
2023-02-25 16:43:36 +00:00
|
|
|
m.queueTypes = []
|
2022-12-02 00:22:00 +00:00
|
|
|
m.position = 0
|
2022-11-29 22:05:46 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
' Clear all content from play queue
|
|
|
|
sub clear()
|
|
|
|
m.queue = []
|
2023-02-25 16:43:36 +00:00
|
|
|
m.queueTypes = []
|
2022-12-02 00:22:00 +00:00
|
|
|
setPosition(0)
|
2022-11-29 22:05:46 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
' Delete item from play queue at passed index
|
|
|
|
sub deleteAtIndex(index)
|
|
|
|
m.queue.Delete(index)
|
2023-02-25 16:43:36 +00:00
|
|
|
m.queueTypes.Delete(index)
|
2022-11-29 22:05:46 +00:00
|
|
|
end sub
|
|
|
|
|
2022-12-02 00:22:00 +00:00
|
|
|
' Return the number of items in the play queue
|
|
|
|
function getCount()
|
|
|
|
return m.queue.count()
|
|
|
|
end function
|
|
|
|
|
|
|
|
' Return the item currently in focus from the play queue
|
|
|
|
function getCurrentItem()
|
|
|
|
return getItemByIndex(m.position)
|
|
|
|
end function
|
|
|
|
|
2022-11-29 22:05:46 +00:00
|
|
|
' Return the item in the passed index from the play queue
|
|
|
|
function getItemByIndex(index)
|
|
|
|
return m.queue[index]
|
|
|
|
end function
|
|
|
|
|
2022-12-02 00:22:00 +00:00
|
|
|
' Returns current playback position within the queue
|
|
|
|
function getPosition()
|
|
|
|
return m.position
|
|
|
|
end function
|
|
|
|
|
|
|
|
' Move queue position back one
|
|
|
|
sub moveBack()
|
|
|
|
m.position--
|
|
|
|
end sub
|
|
|
|
|
|
|
|
' Move queue position ahead one
|
|
|
|
sub moveForward()
|
|
|
|
m.position++
|
|
|
|
end sub
|
|
|
|
|
2022-11-29 22:05:46 +00:00
|
|
|
' Return the current play queue
|
|
|
|
function getQueue()
|
|
|
|
return m.queue
|
|
|
|
end function
|
|
|
|
|
2023-02-25 16:43:36 +00:00
|
|
|
' Return the types of items in current play queue
|
|
|
|
function getQueueTypes()
|
|
|
|
return m.queueTypes
|
|
|
|
end function
|
|
|
|
|
|
|
|
' Return the unique types of items in current play queue
|
|
|
|
function getQueueUniqueTypes()
|
|
|
|
itemTypes = []
|
|
|
|
|
|
|
|
for each item in getQueueTypes()
|
|
|
|
if not inArray(itemTypes, item)
|
|
|
|
itemTypes.push(item)
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
|
|
|
|
return itemTypes
|
|
|
|
end function
|
|
|
|
|
2022-11-29 22:05:46 +00:00
|
|
|
' Return item at end of play queue without removing
|
|
|
|
function peek()
|
|
|
|
return m.queue.peek()
|
|
|
|
end function
|
|
|
|
|
|
|
|
' Play items in queue
|
|
|
|
sub playQueue()
|
2023-02-25 16:43:36 +00:00
|
|
|
nextItem = getCurrentItem()
|
|
|
|
nextItemMediaType = getItemType(nextItem)
|
2022-11-29 22:05:46 +00:00
|
|
|
|
|
|
|
if not isValid(nextItemMediaType) then return
|
|
|
|
|
|
|
|
if nextItemMediaType = "audio"
|
|
|
|
CreateAudioPlayerView()
|
2023-02-25 16:43:36 +00:00
|
|
|
else if nextItemMediaType = "video"
|
|
|
|
CreateVideoPlayerView()
|
|
|
|
else if nextItemMediaType = "episode"
|
|
|
|
CreateVideoPlayerView()
|
2022-11-29 22:05:46 +00:00
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
|
|
|
' Remove item at end of play queue
|
|
|
|
sub pop()
|
|
|
|
m.queue.pop()
|
2023-02-25 16:43:36 +00:00
|
|
|
m.queueTypes.pop()
|
2022-11-29 22:05:46 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
' Push new items to the play queue
|
|
|
|
sub push(newItem)
|
|
|
|
m.queue.push(newItem)
|
2023-02-25 16:43:36 +00:00
|
|
|
m.queueTypes.push(getItemType(newItem))
|
2022-11-29 22:05:46 +00:00
|
|
|
end sub
|
|
|
|
|
2022-12-02 00:22:00 +00:00
|
|
|
' Set the queue position
|
|
|
|
sub setPosition(newPosition)
|
|
|
|
m.position = newPosition
|
|
|
|
end sub
|
|
|
|
|
2022-11-29 22:05:46 +00:00
|
|
|
' Return the fitst item in the play queue
|
|
|
|
function top()
|
|
|
|
return getItemByIndex(0)
|
|
|
|
end function
|
|
|
|
|
|
|
|
' Replace play queue with passed array
|
|
|
|
sub set(items)
|
2022-12-02 00:22:00 +00:00
|
|
|
setPosition(0)
|
2022-11-29 22:05:46 +00:00
|
|
|
m.queue = items
|
2023-02-25 16:43:36 +00:00
|
|
|
for each item in items
|
|
|
|
m.queueTypes.push(getItemType(item))
|
|
|
|
end for
|
2022-11-29 22:05:46 +00:00
|
|
|
end sub
|
2023-02-25 16:43:36 +00:00
|
|
|
|
|
|
|
function getItemType(item) as string
|
2023-03-09 19:35:29 +00:00
|
|
|
if isValid(item) and isValid(item.json) and isValid(item.json.mediatype) and item.json.mediatype <> ""
|
2023-02-25 16:43:36 +00:00
|
|
|
return LCase(item.json.mediatype)
|
2023-03-09 19:35:29 +00:00
|
|
|
else if isValid(item) and isValid(item.type) and item.type <> ""
|
2023-02-25 16:43:36 +00:00
|
|
|
return LCase(item.type)
|
|
|
|
end if
|
|
|
|
|
|
|
|
return invalid
|
|
|
|
end function
|