diff --git a/components/ItemGrid/ItemGrid.brs b/components/ItemGrid/ItemGrid.brs
index 5e34a628..c7615323 100644
--- a/components/ItemGrid/ItemGrid.brs
+++ b/components/ItemGrid/ItemGrid.brs
@@ -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"
diff --git a/components/music/MusicAlbumDetails.brs b/components/music/MusicAlbumDetails.brs
index e988dd29..2833c2cb 100644
--- a/components/music/MusicAlbumDetails.brs
+++ b/components/music/MusicAlbumDetails.brs
@@ -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
diff --git a/components/music/MusicAlbumDetails.xml b/components/music/MusicAlbumDetails.xml
index 8f03a903..0634f4c8 100644
--- a/components/music/MusicAlbumDetails.xml
+++ b/components/music/MusicAlbumDetails.xml
@@ -8,8 +8,8 @@
-
+
@@ -22,6 +22,7 @@
+
diff --git a/source/Main.brs b/source/Main.brs
index ef1c83f1..98e9ef44 100644
--- a/source/Main.brs
+++ b/source/Main.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")
diff --git a/source/ShowScenes.brs b/source/ShowScenes.brs
index e0dd91b5..a790a767 100644
--- a/source/ShowScenes.brs
+++ b/source/ShowScenes.brs
@@ -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,39 +413,70 @@ function CreateVideoPlayerGroup(video_id, mediaSourceId = invalid, audio_stream_
return video
end function
-sub controlaudioplay()
- if m.audio.state = "finished"
+' Play Audio
+function CreateAudioPlayerGroup(audiodata)
+
+ if type(audiodata) = "roArray"
+ ' Passed data is an array of audio, setup playback as a playlist
+
+ m.audio = createObject("RoSGNode", "Audio")
+ m.audio.contentIsPlaylist = true
+
+ audioPlaylistContent = createObject("RoSGNode", "ContentNode")
+
+ for each song in audiodata
+ songContent = audioPlaylistContent.CreateChild("ContentNode")
+ songData = AudioItem(song.id)
+
+ params = {}
+
+ params.append({
+ "Static": "true",
+ "Container": songData.mediaSources[0].container,
+ })
+
+ params.MediaSourceId = songData.mediaSources[0].id
+
+ 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
-end sub
-
-' Play Audio
-function CreateAudioPlayerGroup(audio)
- print "[INFO] Playing ", audio.title
-
- songData = AudioItem(audio.id)
-
- m.audio = createObject("RoSGNode", "Audio")
- m.audio.observeField("state", "controlaudioplay")
- m.audio.content = createObject("RoSGNode", "ContentNode")
-
- 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", audio.id), params)
- m.audio.content.title = audio.title
- m.audio.content.streamformat = songData.mediaSources[0].container
-
- m.audio.control = "stop"
- m.audio.control = "none"
- m.audio.control = "play"
return ""
end function
diff --git a/source/api/Items.brs b/source/api/Items.brs
index 6ae96a21..398189dc 100644
--- a/source/api/Items.brs
+++ b/source/api/Items.brs
@@ -198,12 +198,20 @@ function AudioItem(id as string)
data = getJson(resp)
results = []
- for each item in data.Items
+ 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(item.id)
- tmp.json = item
+ tmp.image = PosterImage(data.id)
+ tmp.json = data
results.push(tmp)
- end for
+ end if
+
data.Items = results
return data
end function