Merge pull request #642 from 1hitsong/music-instant-mix
Add instant mix functionality to album screen
This commit is contained in:
commit
26b856c77a
|
@ -3,6 +3,7 @@ sub init()
|
|||
setupMainNode()
|
||||
|
||||
m.playAlbum = m.top.findNode("playAlbum")
|
||||
m.instantMix = m.top.findNode("instantMix")
|
||||
m.albumCover = m.top.findNode("albumCover")
|
||||
m.songList = m.top.findNode("songList")
|
||||
m.infoGroup = m.top.FindNode("infoGroup")
|
||||
|
@ -99,11 +100,6 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
|||
|
||||
if m.spinner.visible then return false
|
||||
|
||||
' Play Album is hidden, so there are no navigation needs here
|
||||
if m.top.pageContent.json.ChildCount = 1
|
||||
return false
|
||||
end if
|
||||
|
||||
if key = "options"
|
||||
if m.dscr.isTextEllipsized
|
||||
createFullDscrDlg()
|
||||
|
@ -112,10 +108,24 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
|||
return false
|
||||
end if
|
||||
|
||||
if key = "right" and m.playAlbum.hasFocus()
|
||||
m.songList.setFocus(true)
|
||||
return true
|
||||
if key = "right"
|
||||
if m.playAlbum.hasFocus() or m.instantMix.hasFocus()
|
||||
m.songList.setFocus(true)
|
||||
return true
|
||||
end if
|
||||
else if key = "left" and m.songList.hasFocus()
|
||||
if m.playAlbum.visible
|
||||
m.playAlbum.setFocus(true)
|
||||
else if m.instantMix.visible
|
||||
m.instantMix.setFocus(true)
|
||||
else
|
||||
return false
|
||||
end if
|
||||
return true
|
||||
else if key = "down" and m.playAlbum.hasFocus()
|
||||
m.instantMix.setFocus(true)
|
||||
return true
|
||||
else if key = "up" and m.instantMix.hasFocus()
|
||||
m.playAlbum.setFocus(true)
|
||||
return true
|
||||
end if
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<Label id="runtime" width="450" height="25" />
|
||||
<Label id="released" width="450" height="25" />
|
||||
<JFButton id="playAlbum" minChars="8" text="Play Album"></JFButton>
|
||||
<JFButton id="instantMix" minChars="8" text="Instant Mix"></JFButton>
|
||||
</LayoutGroup>
|
||||
<LayoutGroup id="infoGroup" layoutDirection="vert" itemSpacings="[15]">
|
||||
<Label id="overview" wrap="true" height="310" width="1250" ellipsisText=" ... (Press * to read more)" />
|
||||
|
@ -26,6 +27,7 @@
|
|||
<field id="albumData" type="assocarray" alias="songList.MusicArtistAlbumData" />
|
||||
<field id="playSong" alias="songList.itemSelected" />
|
||||
<field id="playAllSelected" alias="playAlbum.buttonSelected" />
|
||||
<field id="instantMixSelected" alias="instantMix.buttonSelected" />
|
||||
</interface>
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/misc.brs" />
|
||||
<script type="text/brightscript" uri="MusicAlbumDetails.brs" />
|
||||
|
|
|
@ -201,6 +201,13 @@ sub Main (args as dynamic) as void
|
|||
m.spinner = screenContent.findNode("spinner")
|
||||
m.spinner.visible = true
|
||||
group = CreateAudioPlayerGroup(screenContent.albumData.items)
|
||||
else if isNodeEvent(msg, "instantMixSelected")
|
||||
' User has selected instant mix
|
||||
' User has selected playlist of of audio they want us to play
|
||||
screenContent = msg.getRoSGNode()
|
||||
m.spinner = screenContent.findNode("spinner")
|
||||
m.spinner.visible = true
|
||||
group = CreateInstantMixGroup(screenContent.albumData.items)
|
||||
else if isNodeEvent(msg, "episodeSelected")
|
||||
' If you select a TV Episode from ANYWHERE, follow this flow
|
||||
node = getMsgPicker(msg, "picker")
|
||||
|
|
|
@ -380,6 +380,7 @@ function CreateMusicArtistDetailsGroup(musicartist)
|
|||
group.albumData = MusicSongList(musicartist.id)
|
||||
group.observeField("playSong", m.port)
|
||||
group.observeField("playAllSelected", m.port)
|
||||
group.observeField("instantMixSelected", m.port)
|
||||
else
|
||||
' User has albums under artists
|
||||
group = CreateObject("roSGNode", "MusicArtistDetails")
|
||||
|
@ -407,6 +408,9 @@ function CreateMusicAlbumDetailsGroup(album)
|
|||
' Watch for user click on Play button on album
|
||||
group.observeField("playAllSelected", m.port)
|
||||
|
||||
' Watch for user click on Instant Mix button on album
|
||||
group.observeField("instantMixSelected", m.port)
|
||||
|
||||
return group
|
||||
end function
|
||||
|
||||
|
@ -481,6 +485,30 @@ function CreateAudioPlayerGroup(audiodata)
|
|||
return group
|
||||
end function
|
||||
|
||||
' Play Instant Mix
|
||||
function CreateInstantMixGroup(audiodata)
|
||||
|
||||
songList = CreateInstantMix(audiodata[0].id)
|
||||
|
||||
group = CreateObject("roSGNode", "NowPlaying")
|
||||
group.observeField("state", m.port)
|
||||
songIDArray = CreateObject("roArray", 0, true)
|
||||
|
||||
' All we need is an array of Song IDs the user selected to play.
|
||||
for each song in songList.items
|
||||
songIDArray.push(song.id)
|
||||
end for
|
||||
|
||||
songIDArray.shift()
|
||||
|
||||
group.pageContent = songIDArray
|
||||
group.musicArtistAlbumData = songList.items
|
||||
|
||||
m.global.sceneManager.callFunc("pushScene", group)
|
||||
|
||||
return group
|
||||
end function
|
||||
|
||||
function CreatePersonView(personData as object) as object
|
||||
person = CreateObject("roSGNode", "PersonDetails")
|
||||
m.global.SceneManager.callFunc("pushScene", person)
|
||||
|
|
|
@ -209,6 +209,17 @@ function AudioItem(id as string)
|
|||
return getJson(resp)
|
||||
end function
|
||||
|
||||
' Get Instant Mix based on item
|
||||
function CreateInstantMix(id as string)
|
||||
url = Substitute("/Items/{0}/InstantMix", id)
|
||||
resp = APIRequest(url, {
|
||||
"UserId": get_setting("active_user"),
|
||||
"Limit": 201
|
||||
})
|
||||
|
||||
return getJson(resp)
|
||||
end function
|
||||
|
||||
function AudioStream(id as string)
|
||||
songData = AudioItem(id)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user