Add button to play album
This commit is contained in:
parent
52bf0c35c6
commit
00df907c94
|
@ -101,7 +101,7 @@ sub loadInitialItems()
|
|||
else if m.top.parentItem.collectionType = "tvshows"
|
||||
m.loadItemsTask.itemType = "Series"
|
||||
else if m.top.parentItem.collectionType = "music"
|
||||
m.loadItemsTask.itemType = "Music"
|
||||
m.loadItemsTask.itemType = "MusicArtist"
|
||||
m.loadItemsTask.recursive = false
|
||||
else if m.top.parentItem.collectionType = "livetv"
|
||||
m.loadItemsTask.itemType = "LiveTV"
|
||||
|
|
|
@ -2,6 +2,8 @@ sub init()
|
|||
m.top.optionsAvailable = false
|
||||
main = m.top.findNode("toplevel")
|
||||
main.translation = [96, 175]
|
||||
m.playAlbum = m.top.findNode("playAlbum")
|
||||
m.songList = m.top.findNode("songList")
|
||||
end sub
|
||||
|
||||
' Set values for displayed values on screen
|
||||
|
@ -69,5 +71,13 @@ end function
|
|||
function onKeyEvent(key as string, press as boolean) as boolean
|
||||
if not press then return false
|
||||
|
||||
if key = "right" and m.playAlbum.hasFocus()
|
||||
m.songList.setFocus(true)
|
||||
return true
|
||||
else if key = "left" and m.songList.hasFocus()
|
||||
m.playAlbum.setFocus(true)
|
||||
return true
|
||||
end if
|
||||
|
||||
return false
|
||||
end function
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<Label id="numberofsongs" width="450" height="25" />
|
||||
<Label id="genres" width="450" height="25" />
|
||||
<Label id="runtime" width="450" height="25" />
|
||||
|
||||
<Label id="released" width="450" height="25" />
|
||||
<JFButton id="playAlbum" minChars="8" text="Play"></JFButton>
|
||||
</LayoutGroup>
|
||||
<LayoutGroup layoutDirection="vert" itemSpacings="[15]">
|
||||
<Label id="overview" wrap="true" width="1250" maxLines="5" />
|
||||
|
@ -22,6 +22,7 @@
|
|||
<field id="itemContent" type="node" onChange="itemContentChanged" />
|
||||
<field id="musicArtistAlbumData" type="assocarray" alias="songList.MusicArtistAlbumData" />
|
||||
<field id="musicSongSelected" alias="songList.itemSelected" />
|
||||
<field id="playAllSelected" alias="playAlbum.buttonSelected" />
|
||||
</interface>
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/misc.brs" />
|
||||
<script type="text/brightscript" uri="MusicAlbumDetails.brs" />
|
||||
|
|
|
@ -191,6 +191,10 @@ sub Main (args as dynamic) as void
|
|||
selectedIndex = msg.getData()
|
||||
songs = msg.getRoSGNode()
|
||||
group = CreateAudioPlayerGroup(songs.MusicArtistAlbumData.items[selectedIndex])
|
||||
else if isNodeEvent(msg, "playAllSelected")
|
||||
' User selected Play All button
|
||||
songs = msg.getRoSGNode()
|
||||
group = CreateAudioPlayerGroup(songs.MusicArtistAlbumData.items)
|
||||
else if isNodeEvent(msg, "episodeSelected")
|
||||
' If you select a TV Episode from ANYWHERE, follow this flow
|
||||
node = getMsgPicker(msg, "picker")
|
||||
|
|
|
@ -356,6 +356,9 @@ function CreateMusicAlbumDetailsGroup(album)
|
|||
' Watch for user clicking on a song
|
||||
group.observeField("musicSongSelected", m.port)
|
||||
|
||||
' Watch for user click on Play button on album
|
||||
group.observeField("playAllSelected", m.port)
|
||||
|
||||
return group
|
||||
end function
|
||||
|
||||
|
@ -410,22 +413,20 @@ function CreateVideoPlayerGroup(video_id, mediaSourceId = invalid, audio_stream_
|
|||
return video
|
||||
end function
|
||||
|
||||
sub controlaudioplay()
|
||||
if m.audio.state = "finished"
|
||||
m.audio.control = "stop"
|
||||
m.audio.control = "none"
|
||||
end if
|
||||
end sub
|
||||
|
||||
' Play Audio
|
||||
function CreateAudioPlayerGroup(audio)
|
||||
print "[INFO] Playing ", audio.title
|
||||
function CreateAudioPlayerGroup(audiodata)
|
||||
|
||||
songData = AudioItem(audio.id)
|
||||
if type(audiodata) = "roArray"
|
||||
' Passed data is an array of audio, setup playback as a playlist
|
||||
|
||||
m.audio = createObject("RoSGNode", "Audio")
|
||||
m.audio.observeField("state", "controlaudioplay")
|
||||
m.audio.content = createObject("RoSGNode", "ContentNode")
|
||||
m.audio.contentIsPlaylist = true
|
||||
|
||||
audioPlaylistContent = createObject("RoSGNode", "ContentNode")
|
||||
|
||||
for each song in audiodata
|
||||
songContent = audioPlaylistContent.CreateChild("ContentNode")
|
||||
songData = AudioItem(song.id)
|
||||
|
||||
params = {}
|
||||
|
||||
|
@ -436,13 +437,46 @@ function CreateAudioPlayerGroup(audio)
|
|||
|
||||
params.MediaSourceId = songData.mediaSources[0].id
|
||||
|
||||
m.audio.content.url = buildURL(Substitute("Audio/{0}/stream", audio.id), params)
|
||||
m.audio.content.title = audio.title
|
||||
songContent.url = buildURL(Substitute("Audio/{0}/stream", song.id), params)
|
||||
songContent.title = song.title
|
||||
songContent.streamformat = songData.mediaSources[0].container
|
||||
end for
|
||||
|
||||
m.audio.content = audioPlaylistContent
|
||||
|
||||
m.audio.control = "stop"
|
||||
m.audio.control = "none"
|
||||
m.audio.control = "play"
|
||||
|
||||
else if type(audiodata) = "roSGNode"
|
||||
' Passed data is a single node
|
||||
|
||||
if audiodata.subtype() = "MusicSongData"
|
||||
' Passed data is data for a single song, setup playback as a single song
|
||||
|
||||
m.audio = createObject("RoSGNode", "Audio")
|
||||
m.audio.content = createObject("RoSGNode", "ContentNode")
|
||||
|
||||
songData = AudioItem(audiodata.id)
|
||||
|
||||
params = {}
|
||||
|
||||
params.append({
|
||||
"Static": "true",
|
||||
"Container": songData.mediaSources[0].container,
|
||||
})
|
||||
|
||||
params.MediaSourceId = songData.mediaSources[0].id
|
||||
|
||||
m.audio.content.url = buildURL(Substitute("Audio/{0}/stream", audiodata.id), params)
|
||||
m.audio.content.title = audiodata.title
|
||||
m.audio.content.streamformat = songData.mediaSources[0].container
|
||||
|
||||
m.audio.control = "stop"
|
||||
m.audio.control = "none"
|
||||
m.audio.control = "play"
|
||||
end if
|
||||
end if
|
||||
|
||||
return ""
|
||||
end function
|
||||
|
|
|
@ -198,12 +198,20 @@ function AudioItem(id as string)
|
|||
|
||||
data = getJson(resp)
|
||||
results = []
|
||||
if data.Items <> invalid
|
||||
for each item in data.Items
|
||||
tmp = CreateObject("roSGNode", "MusicSongData")
|
||||
tmp.image = PosterImage(item.id)
|
||||
tmp.json = item
|
||||
results.push(tmp)
|
||||
end for
|
||||
else
|
||||
tmp = CreateObject("roSGNode", "MusicSongData")
|
||||
tmp.image = PosterImage(data.id)
|
||||
tmp.json = data
|
||||
results.push(tmp)
|
||||
end if
|
||||
|
||||
data.Items = results
|
||||
return data
|
||||
end function
|
||||
|
|
Loading…
Reference in New Issue
Block a user