2023-10-03 16:11:25 +00:00
|
|
|
import "pkg:/source/utils/misc.bs"
|
2023-05-03 21:21:04 +00:00
|
|
|
|
2022-05-14 02:35:50 +00:00
|
|
|
sub init()
|
|
|
|
m.top.optionsAvailable = false
|
2022-05-21 20:45:01 +00:00
|
|
|
setupMainNode()
|
2022-07-19 02:28:06 +00:00
|
|
|
setupButtons()
|
|
|
|
|
2022-09-03 20:06:57 +00:00
|
|
|
m.remoteButtonsActive = true
|
|
|
|
|
2022-07-19 02:28:06 +00:00
|
|
|
m.albumHeader = m.top.findNode("albumHeader")
|
|
|
|
m.albumHeader.text = tr("Albums")
|
|
|
|
|
2022-09-27 01:26:17 +00:00
|
|
|
m.appearsOnHeader = m.top.findNode("appearsOnHeader")
|
|
|
|
m.appearsOnHeader.text = tr("AppearsOn")
|
|
|
|
|
|
|
|
m.appearsOn = m.top.findNode("appearsOn")
|
|
|
|
m.appearsOn.observeField("escape", "onAppearsOnEscape")
|
|
|
|
m.appearsOn.observeField("MusicArtistAlbumData", "onAppearsOnData")
|
|
|
|
|
2022-07-19 02:28:06 +00:00
|
|
|
m.albums = m.top.findNode("albums")
|
2022-09-03 20:06:57 +00:00
|
|
|
m.albums.observeField("escape", "onAlbumsEscape")
|
2022-09-27 01:26:17 +00:00
|
|
|
m.albums.observeField("MusicArtistAlbumData", "onAlbumsData")
|
2022-07-19 02:28:06 +00:00
|
|
|
|
|
|
|
m.pageLoadAnimation = m.top.findNode("pageLoad")
|
|
|
|
m.pageLoadAnimation.control = "start"
|
|
|
|
|
2022-09-02 08:12:40 +00:00
|
|
|
m.sectionNavigation = m.top.findNode("sectionNavigation")
|
|
|
|
m.sectionNavigation.observeField("escape", "onSectionNavigationEscape")
|
|
|
|
m.sectionNavigation.observeField("selected", "onSectionNavigationSelected")
|
|
|
|
|
2022-09-03 20:06:57 +00:00
|
|
|
m.sectionScroller = m.top.findNode("sectionScroller")
|
2022-09-19 23:34:36 +00:00
|
|
|
m.sectionScroller.observeField("displayedIndex", "onSectionScrollerChange")
|
|
|
|
m.overhang = m.top.getScene().findNode("overhang")
|
2022-09-03 20:06:57 +00:00
|
|
|
|
2022-06-09 23:50:05 +00:00
|
|
|
' Load background image
|
|
|
|
m.LoadBackdropImageTask = CreateObject("roSGNode", "LoadItemsTask")
|
|
|
|
m.LoadBackdropImageTask.itemsToLoad = "backdropImage"
|
|
|
|
|
|
|
|
m.backDrop = m.top.findNode("backdrop")
|
2022-05-31 19:56:20 +00:00
|
|
|
m.artistImage = m.top.findNode("artistImage")
|
|
|
|
m.dscr = m.top.findNode("overview")
|
|
|
|
m.dscr.observeField("isTextEllipsized", "onEllipsisChanged")
|
|
|
|
createDialogPallete()
|
2022-05-21 20:45:01 +00:00
|
|
|
end sub
|
|
|
|
|
2022-09-27 01:26:17 +00:00
|
|
|
sub onAlbumsData()
|
|
|
|
' We have no album data
|
|
|
|
if m.albums.MusicArtistAlbumData.TotalRecordCount = 0
|
|
|
|
m.sectionScroller.removeChild(m.top.findNode("albumsSlide"))
|
|
|
|
m.sectionNavigation.removeChild(m.top.findNode("albumsLink"))
|
|
|
|
m.top.findNode("appearsOnSlide").callFunc("scrollUpToOnDeck")
|
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub onAppearsOnData()
|
|
|
|
' We have no appears on data
|
|
|
|
if m.appearsOn.MusicArtistAlbumData.TotalRecordCount = 0
|
|
|
|
m.sectionScroller.removeChild(m.top.findNode("appearsOnSlide"))
|
|
|
|
m.sectionNavigation.removeChild(m.top.findNode("appearsOnLink"))
|
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
2022-09-19 23:34:36 +00:00
|
|
|
sub onSectionScrollerChange()
|
|
|
|
m.overhang.isVisible = (m.sectionScroller.displayedIndex = 0)
|
|
|
|
end sub
|
|
|
|
|
2022-09-27 01:26:17 +00:00
|
|
|
sub OnScreenShown()
|
|
|
|
m.sectionScroller.focus = true
|
|
|
|
|
|
|
|
if m.sectionScroller.displayedIndex = 0
|
|
|
|
m.previouslySelectedButtonIndex = m.top.selectedButtonIndex
|
|
|
|
m.top.selectedButtonIndex = 0
|
|
|
|
m.buttonGrp.setFocus(true)
|
|
|
|
else
|
|
|
|
m.overhang.opacity = "0"
|
|
|
|
m.overhang.isVisible = false
|
|
|
|
m.overhang.opacity = "1"
|
|
|
|
end if
|
2023-11-22 02:14:40 +00:00
|
|
|
stopLoadingSpinner()
|
2022-09-27 01:26:17 +00:00
|
|
|
end sub
|
|
|
|
|
2022-09-19 23:34:36 +00:00
|
|
|
sub OnScreenHidden()
|
|
|
|
if not m.overhang.isVisible
|
|
|
|
m.overhang.disableMoveAnimation = true
|
|
|
|
m.overhang.isVisible = true
|
|
|
|
m.overhang.disableMoveAnimation = false
|
2022-09-27 01:26:17 +00:00
|
|
|
m.overhang.opacity = "1"
|
2022-09-19 23:34:36 +00:00
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
2022-09-03 20:06:57 +00:00
|
|
|
sub onAlbumsEscape()
|
|
|
|
if m.albums.escape = "up"
|
|
|
|
m.sectionNavigation.selected = m.sectionScroller.displayedIndex - 1
|
|
|
|
else if m.albums.escape = "left"
|
|
|
|
m.sectionNavigation.setFocus(true)
|
2022-09-27 01:26:17 +00:00
|
|
|
else if m.albums.escape = "down"
|
|
|
|
if m.sectionScroller.displayedIndex + 1 < m.sectionNavigation.getChildCount()
|
|
|
|
m.sectionNavigation.selected = m.sectionScroller.displayedIndex + 1
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub onAppearsOnEscape()
|
|
|
|
if m.appearsOn.escape = "up"
|
|
|
|
m.sectionNavigation.selected = m.sectionScroller.displayedIndex - 1
|
|
|
|
else if m.appearsOn.escape = "left"
|
|
|
|
m.sectionNavigation.setFocus(true)
|
2022-09-03 20:06:57 +00:00
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
2022-07-19 02:28:06 +00:00
|
|
|
' Setup playback buttons, default to Play button selected
|
|
|
|
sub setupButtons()
|
|
|
|
m.buttonGrp = m.top.findNode("buttons")
|
|
|
|
m.buttonCount = m.buttonGrp.getChildCount()
|
|
|
|
|
|
|
|
m.playButton = m.top.findNode("play")
|
|
|
|
m.previouslySelectedButtonIndex = -1
|
|
|
|
|
|
|
|
m.top.observeField("selectedButtonIndex", "onButtonSelectedChange")
|
|
|
|
m.top.selectedButtonIndex = 0
|
|
|
|
end sub
|
|
|
|
|
|
|
|
' Event handler when user selected a different playback button
|
|
|
|
sub onButtonSelectedChange()
|
|
|
|
' Change previously selected button back to default image
|
|
|
|
if m.previouslySelectedButtonIndex > -1
|
2022-09-03 20:06:57 +00:00
|
|
|
previousSelectedButton = m.buttonGrp.getChild(m.previouslySelectedButtonIndex)
|
|
|
|
previousSelectedButton.focus = false
|
2022-07-19 02:28:06 +00:00
|
|
|
end if
|
|
|
|
|
|
|
|
' Change selected button image to selected image
|
|
|
|
selectedButton = m.buttonGrp.getChild(m.top.selectedButtonIndex)
|
2022-09-03 20:06:57 +00:00
|
|
|
selectedButton.focus = true
|
2022-07-19 02:28:06 +00:00
|
|
|
end sub
|
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
sub setupMainNode()
|
2022-07-19 02:28:06 +00:00
|
|
|
m.main = m.top.findNode("toplevel")
|
2022-09-02 08:12:40 +00:00
|
|
|
m.main.translation = [120, 175]
|
2022-05-14 02:35:50 +00:00
|
|
|
end sub
|
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
' Event fired when page data is loaded
|
|
|
|
sub pageContentChanged()
|
|
|
|
item = m.top.pageContent
|
2022-05-14 02:35:50 +00:00
|
|
|
|
2022-06-09 23:50:05 +00:00
|
|
|
' Use metadata to load backdrop image
|
|
|
|
m.LoadBackdropImageTask.itemId = item.json.id
|
|
|
|
m.LoadBackdropImageTask.observeField("content", "onBackdropImageLoaded")
|
|
|
|
m.LoadBackdropImageTask.control = "RUN"
|
|
|
|
|
2022-05-14 21:14:15 +00:00
|
|
|
' Populate scene data
|
2022-05-21 20:45:01 +00:00
|
|
|
setScreenTitle(item.json)
|
|
|
|
setPosterImage(item.posterURL)
|
2022-05-14 02:35:50 +00:00
|
|
|
end sub
|
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
sub setScreenTitle(json)
|
|
|
|
if isValid(json)
|
|
|
|
m.top.overhangTitle = json.name
|
|
|
|
end if
|
|
|
|
end sub
|
2022-05-14 02:35:50 +00:00
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
sub setPosterImage(posterURL)
|
2022-07-19 02:28:06 +00:00
|
|
|
if not isValid(posterURL) or posterURL = ""
|
|
|
|
posterURL = "pkg:/images/missingArtist.png"
|
2022-05-14 02:35:50 +00:00
|
|
|
end if
|
2022-07-19 02:28:06 +00:00
|
|
|
|
|
|
|
m.artistImage.uri = posterURL
|
2022-05-21 20:45:01 +00:00
|
|
|
end sub
|
2022-05-14 02:35:50 +00:00
|
|
|
|
2022-06-09 23:50:05 +00:00
|
|
|
sub onBackdropImageLoaded()
|
|
|
|
data = m.LoadBackdropImageTask.content[0]
|
|
|
|
m.LoadBackdropImageTask.unobserveField("content")
|
|
|
|
if isValid(data) and data <> ""
|
|
|
|
setBackdropImage(data)
|
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
|
|
|
' Add backdrop image to screen
|
|
|
|
sub setBackdropImage(data)
|
|
|
|
if isValid(data)
|
|
|
|
if m.backDrop.uri <> data
|
|
|
|
m.backDrop.uri = data
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
2022-09-27 01:26:17 +00:00
|
|
|
' Event fired when page data is loaded
|
|
|
|
sub artistOverviewChanged()
|
|
|
|
overviewContent = m.top.artistOverview
|
|
|
|
|
|
|
|
if isValid(overviewContent)
|
|
|
|
setFieldTextValue("overview", overviewContent)
|
2022-05-21 20:45:01 +00:00
|
|
|
end if
|
2022-05-14 02:35:50 +00:00
|
|
|
end sub
|
|
|
|
|
2022-05-31 19:56:20 +00:00
|
|
|
sub onEllipsisChanged()
|
|
|
|
if m.dscr.isTextEllipsized
|
|
|
|
dscrShowFocus()
|
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
2022-09-02 08:12:40 +00:00
|
|
|
sub onSectionNavigationEscape()
|
|
|
|
if m.sectionNavigation.escape = "right"
|
2022-09-03 20:06:57 +00:00
|
|
|
m.sectionNavigation.setFocus(false)
|
|
|
|
m.remoteButtonsActive = false
|
|
|
|
m.sectionScroller.focus = true
|
2022-09-02 08:12:40 +00:00
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub onSectionNavigationSelected()
|
2022-09-03 20:06:57 +00:00
|
|
|
m.sectionScroller.displayedIndex = m.sectionNavigation.selected
|
2022-09-02 08:12:40 +00:00
|
|
|
end sub
|
|
|
|
|
2022-05-31 19:56:20 +00:00
|
|
|
sub dscrShowFocus()
|
|
|
|
if m.dscr.isTextEllipsized
|
|
|
|
m.dscr.setFocus(true)
|
|
|
|
m.dscr.opacity = 1.0
|
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub createFullDscrDlg()
|
|
|
|
dlg = CreateObject("roSGNode", "OverviewDialog")
|
|
|
|
dlg.Title = tr("Press 'Back' to Close")
|
|
|
|
dlg.width = 1290
|
|
|
|
dlg.palette = m.dlgPalette
|
|
|
|
dlg.overview = [m.dscr.text]
|
|
|
|
m.fullDscrDlg = dlg
|
|
|
|
m.top.getScene().dialog = dlg
|
|
|
|
border = createObject("roSGNode", "Poster")
|
|
|
|
border.uri = "pkg:/images/hd_focul_9.png"
|
|
|
|
border.blendColor = "#c9c9c9ff"
|
|
|
|
border.width = dlg.width + 6
|
|
|
|
border.height = dlg.height + 6
|
|
|
|
border.translation = [dlg.translation[0] - 3, dlg.translation[1] - 3]
|
|
|
|
border.visible = true
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub createDialogPallete()
|
|
|
|
m.dlgPalette = createObject("roSGNode", "RSGPalette")
|
|
|
|
m.dlgPalette.colors = {
|
|
|
|
DialogBackgroundColor: "0x262828FF",
|
|
|
|
DialogItemColor: "0x00EF00FF",
|
|
|
|
DialogTextColor: "0xb0b0b0FF",
|
|
|
|
DialogFocusColor: "0xcececeFF",
|
|
|
|
DialogFocusItemColor: "0x202020FF",
|
|
|
|
DialogSecondaryTextColor: "0xf8f8f8ff",
|
|
|
|
DialogSecondaryItemColor: "0xcc7ecc4D",
|
|
|
|
DialogInputFieldColor: "0x80FF8080",
|
|
|
|
DialogKeyboardColor: "0x80FF804D",
|
|
|
|
DialogFootprintColor: "0x80FF804D"
|
|
|
|
}
|
|
|
|
end sub
|
|
|
|
|
2022-05-14 02:35:50 +00:00
|
|
|
function onKeyEvent(key as string, press as boolean) as boolean
|
2022-09-03 20:06:57 +00:00
|
|
|
|
|
|
|
if m.buttonGrp.isInFocusChain()
|
2022-09-27 01:26:17 +00:00
|
|
|
if key = "OK"
|
|
|
|
if press
|
|
|
|
selectedButton = m.buttonGrp.getChild(m.top.selectedButtonIndex)
|
|
|
|
selectedButton.selected = not selectedButton.selected
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
2022-09-03 20:06:57 +00:00
|
|
|
if key = "left"
|
2022-07-19 02:28:06 +00:00
|
|
|
if m.top.selectedButtonIndex > 0
|
|
|
|
m.previouslySelectedButtonIndex = m.top.selectedButtonIndex
|
|
|
|
m.top.selectedButtonIndex = m.top.selectedButtonIndex - 1
|
2022-09-02 08:12:40 +00:00
|
|
|
return true
|
2022-07-19 02:28:06 +00:00
|
|
|
end if
|
2022-09-02 08:12:40 +00:00
|
|
|
|
|
|
|
if press
|
2022-09-03 20:06:57 +00:00
|
|
|
selectedButton = m.buttonGrp.getChild(m.top.selectedButtonIndex)
|
|
|
|
selectedButton.focus = false
|
|
|
|
|
2022-09-02 08:12:40 +00:00
|
|
|
m.sectionNavigation.setFocus(true)
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
|
|
|
|
return false
|
|
|
|
end if
|
|
|
|
|
2022-09-03 20:06:57 +00:00
|
|
|
if key = "right"
|
|
|
|
if m.top.pageContent.count() = 1 then return false
|
|
|
|
|
|
|
|
if m.buttonGrp.getChild(m.top.selectedButtonIndex).escape = "right"
|
|
|
|
m.buttonGrp.getChild(m.top.selectedButtonIndex).escape = ""
|
|
|
|
m.previouslySelectedButtonIndex = m.top.selectedButtonIndex
|
|
|
|
|
|
|
|
if m.top.selectedButtonIndex < m.buttonCount - 1
|
|
|
|
m.top.selectedButtonIndex = m.top.selectedButtonIndex + 1
|
|
|
|
end if
|
|
|
|
|
2022-09-02 08:12:40 +00:00
|
|
|
return true
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
if key = "down"
|
2022-09-27 01:26:17 +00:00
|
|
|
if m.sectionNavigation.getChildCount() > 1
|
|
|
|
selectedButton = m.buttonGrp.getChild(m.top.selectedButtonIndex)
|
|
|
|
selectedButton.focus = false
|
2022-07-19 02:28:06 +00:00
|
|
|
|
2022-09-27 01:26:17 +00:00
|
|
|
m.top.selectedButtonIndex = 0
|
|
|
|
m.sectionNavigation.selected = m.sectionScroller.displayedIndex + 1
|
|
|
|
end if
|
2022-07-19 02:28:06 +00:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
2022-05-31 19:56:20 +00:00
|
|
|
if not press then return false
|
|
|
|
|
|
|
|
if key = "options"
|
|
|
|
if m.dscr.isTextEllipsized
|
|
|
|
createFullDscrDlg()
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
2023-09-16 21:18:03 +00:00
|
|
|
if key = "play"
|
2023-09-19 02:39:44 +00:00
|
|
|
print "play button pressed from ArtistView"
|
|
|
|
itemToPlay = invalid
|
|
|
|
|
|
|
|
if isValid(m.albums) and m.albums.isInFocusChain()
|
|
|
|
itemToPlay = m.albums.MusicArtistAlbumData.items[m.albums.itemFocused]
|
|
|
|
else if isValid(m.appearsOn) and m.appearsOn.isInFocusChain()
|
|
|
|
itemToPlay = m.appearsOn.MusicArtistAlbumData.items[m.appearsOn.itemFocused]
|
|
|
|
end if
|
|
|
|
|
2023-09-16 21:18:03 +00:00
|
|
|
if isValid(itemToPlay)
|
|
|
|
m.top.quickPlayNode = itemToPlay
|
2023-09-19 02:39:44 +00:00
|
|
|
return true
|
2023-09-16 21:18:03 +00:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
2022-05-14 02:35:50 +00:00
|
|
|
return false
|
|
|
|
end function
|