2023-05-03 21:21:04 +00:00
|
|
|
import "pkg:/source/utils/misc.brs"
|
|
|
|
|
2022-05-14 15:47:44 +00:00
|
|
|
sub init()
|
|
|
|
m.top.optionsAvailable = false
|
2022-05-21 20:45:01 +00:00
|
|
|
setupMainNode()
|
|
|
|
|
2022-05-15 19:10:21 +00:00
|
|
|
m.playAlbum = m.top.findNode("playAlbum")
|
2022-06-08 13:08:05 +00:00
|
|
|
m.instantMix = m.top.findNode("instantMix")
|
2022-05-31 19:56:20 +00:00
|
|
|
m.albumCover = m.top.findNode("albumCover")
|
2022-05-15 19:10:21 +00:00
|
|
|
m.songList = m.top.findNode("songList")
|
2022-05-31 19:56:20 +00:00
|
|
|
m.infoGroup = m.top.FindNode("infoGroup")
|
|
|
|
m.songListRect = m.top.FindNode("songListRect")
|
2022-05-22 21:32:03 +00:00
|
|
|
|
2022-07-17 16:14:12 +00:00
|
|
|
m.songList.observeField("doneLoading", "onDoneLoading")
|
2022-05-22 21:32:03 +00:00
|
|
|
m.spinner = m.top.findNode("spinner")
|
2022-05-31 11:45:15 +00:00
|
|
|
m.spinner.visible = true
|
2022-05-31 19:56:20 +00:00
|
|
|
|
|
|
|
m.dscr = m.top.findNode("overview")
|
|
|
|
createDialogPallete()
|
2022-05-14 15:47:44 +00:00
|
|
|
end sub
|
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
sub setupMainNode()
|
|
|
|
main = m.top.findNode("toplevel")
|
|
|
|
main.translation = [96, 175]
|
|
|
|
end sub
|
2022-05-14 15:47:44 +00:00
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
' Set values for displayed values on screen
|
|
|
|
sub pageContentChanged()
|
|
|
|
item = m.top.pageContent
|
2022-05-14 21:14:15 +00:00
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
setPosterImage(item.posterURL)
|
|
|
|
setScreenTitle(item.json)
|
|
|
|
setOnScreenTextValues(item.json)
|
2022-05-22 00:03:24 +00:00
|
|
|
|
|
|
|
' Only 1 song shown, so hide Play Album button
|
|
|
|
if item.json.ChildCount = 1
|
2022-05-31 19:56:20 +00:00
|
|
|
m.playAlbum.visible = false
|
2022-05-22 00:03:24 +00:00
|
|
|
end if
|
2022-05-21 20:45:01 +00:00
|
|
|
end sub
|
2022-05-14 21:14:15 +00:00
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
' Set poster image on screen
|
|
|
|
sub setPosterImage(posterURL)
|
|
|
|
if isValid(posterURL)
|
2022-05-31 19:56:20 +00:00
|
|
|
m.albumCover.uri = posterURL
|
2022-05-14 15:47:44 +00:00
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
' Set screen's title text
|
|
|
|
sub setScreenTitle(json)
|
2022-05-22 12:46:53 +00:00
|
|
|
newTitle = ""
|
2022-05-21 20:45:01 +00:00
|
|
|
if isValid(json)
|
2022-05-22 12:46:53 +00:00
|
|
|
if isValid(json.AlbumArtist)
|
|
|
|
newTitle = json.AlbumArtist
|
|
|
|
end if
|
|
|
|
if isValid(json.AlbumArtist) and isValid(json.name)
|
|
|
|
newTitle = newTitle + " / "
|
|
|
|
end if
|
|
|
|
if isValid(json.name)
|
|
|
|
newTitle = newTitle + json.name
|
|
|
|
end if
|
2022-05-14 15:47:44 +00:00
|
|
|
end if
|
2022-05-22 12:46:53 +00:00
|
|
|
m.top.overhangTitle = newTitle
|
2022-05-14 15:47:44 +00:00
|
|
|
end sub
|
|
|
|
|
2022-05-31 19:56:20 +00:00
|
|
|
' Adjust scene by removing overview node and showing more songs
|
|
|
|
sub adjustScreenForNoOverview()
|
|
|
|
m.infoGroup.removeChild(m.dscr)
|
|
|
|
m.songListRect.height = 800
|
|
|
|
m.songList.numRows = 12
|
|
|
|
end sub
|
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
' Populate on screen text variables
|
|
|
|
sub setOnScreenTextValues(json)
|
|
|
|
if isValid(json)
|
2022-06-12 16:11:48 +00:00
|
|
|
if isValid(json.overview) and json.overview <> ""
|
|
|
|
' We have overview text
|
2022-05-31 19:56:20 +00:00
|
|
|
setFieldTextValue("overview", json.overview)
|
|
|
|
else
|
|
|
|
' We don't have overview text
|
|
|
|
adjustScreenForNoOverview()
|
|
|
|
end if
|
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
setFieldTextValue("numberofsongs", stri(json.ChildCount) + " Tracks")
|
2022-05-14 15:47:44 +00:00
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
if type(json.ProductionYear) = "roInt"
|
|
|
|
setFieldTextValue("released", "Released " + stri(json.ProductionYear))
|
|
|
|
end if
|
|
|
|
|
|
|
|
if json.genres.count() > 0
|
|
|
|
setFieldTextValue("genres", json.genres.join(", "))
|
|
|
|
end if
|
2022-05-14 15:47:44 +00:00
|
|
|
|
2022-05-21 20:45:01 +00:00
|
|
|
if type(json.RunTimeTicks) = "LongInteger"
|
|
|
|
setFieldTextValue("runtime", stri(getMinutes(json.RunTimeTicks)) + " mins")
|
|
|
|
end if
|
2022-05-14 15:47:44 +00:00
|
|
|
end if
|
2022-05-21 20:45:01 +00:00
|
|
|
end sub
|
2022-05-14 15:47:44 +00:00
|
|
|
|
|
|
|
function onKeyEvent(key as string, press as boolean) as boolean
|
|
|
|
if not press then return false
|
|
|
|
|
2022-05-31 11:45:15 +00:00
|
|
|
if m.spinner.visible then return false
|
|
|
|
|
2022-05-31 19:56:20 +00:00
|
|
|
if key = "options"
|
|
|
|
if m.dscr.isTextEllipsized
|
|
|
|
createFullDscrDlg()
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
return false
|
|
|
|
end if
|
|
|
|
|
2022-06-08 13:08:05 +00:00
|
|
|
if key = "right"
|
|
|
|
if m.playAlbum.hasFocus() or m.instantMix.hasFocus()
|
|
|
|
m.songList.setFocus(true)
|
|
|
|
return true
|
|
|
|
end if
|
2022-05-15 19:10:21 +00:00
|
|
|
else if key = "left" and m.songList.hasFocus()
|
2022-06-08 14:28:18 +00:00
|
|
|
if m.playAlbum.visible
|
|
|
|
m.playAlbum.setFocus(true)
|
|
|
|
else if m.instantMix.visible
|
|
|
|
m.instantMix.setFocus(true)
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end if
|
2022-05-15 19:10:21 +00:00
|
|
|
return true
|
2022-06-08 13:08:05 +00:00
|
|
|
else if key = "down" and m.playAlbum.hasFocus()
|
|
|
|
m.instantMix.setFocus(true)
|
|
|
|
return true
|
|
|
|
else if key = "up" and m.instantMix.hasFocus()
|
2022-05-15 19:10:21 +00:00
|
|
|
m.playAlbum.setFocus(true)
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
|
2022-05-14 15:47:44 +00:00
|
|
|
return false
|
|
|
|
end function
|
2022-05-22 21:32:03 +00:00
|
|
|
|
2022-05-31 19:56:20 +00:00
|
|
|
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-07-17 16:14:12 +00:00
|
|
|
sub onDoneLoading()
|
|
|
|
m.songList.unobservefield("doneLoading")
|
|
|
|
m.spinner.visible = false
|
|
|
|
end sub
|
|
|
|
|
2022-05-22 21:32:03 +00:00
|
|
|
sub OnScreenHidden()
|
|
|
|
m.spinner.visible = false
|
2022-05-31 20:27:26 +00:00
|
|
|
end sub
|