
squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2013
12:21 PM
back button on array
audio springboard, one button plays an array of 5 items.
stopping advances the audio to the next item in the array, so easy to make a RIGHT button, which cycles through the items.
Problem I'm having is making a LEFT button to cycle the other way.
I was hoping this would work:
It returns a result but not based on the current item playing in the springboard, it always returns the same result which is to play item 2 in the array as it seems to think item 3 is 0.
stopping advances the audio to the next item in the array, so easy to make a RIGHT button, which cycles through the items.
Problem I'm having is making a LEFT button to cycle the other way.
I was hoping this would work:
else if msg.isRemoteKeyPressed()
if msg.GetIndex() = 4 ' < LEFT
scr.ClearButtons()
m.audio.SetNext(msg.GetIndex() -1)
m.audio.Play()
scr.AddButton(2, "Pause")
scr.AddButton(4, "Stop")
scr.AddButton(5, "Done")
It returns a result but not based on the current item playing in the springboard, it always returns the same result which is to play item 2 in the array as it seems to think item 3 is 0.
Kinetics Screensavers
3 REPLIES 3

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2013
01:30 PM
Re: back button on array
because msg.getindex() is returning the index for which remote key is pressed and not the index value for your array. You could create an index variable to reflect current position, and increment or decrement that variable depending on which key is pressed.
Then:
- Joel
Then:
else if msg.isRemoteKeyPressed()
if msg.GetIndex() = 4 ' < LEFT
scr.ClearButtons()
if index > 0 then index=index-1
if index=0 then index=playlist.count()-1
m.audio.SetNext(msg.GetIndex() -1)
m.audio.Play()
scr.AddButton(2, "Pause")
scr.AddButton(4, "Stop")
scr.AddButton(5, "Done")
- Joel

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2013
10:40 AM
Re: back button on array
"RokuJoel" wrote:
because msg.getindex() is returning the index for which remote key is pressed and not the index value for your array. You could create an index variable to reflect current position, and increment or decrement that variable depending on which key is pressed.
- Joel
Thank You Joel, I will try to do that if i can figure out how to get the current position of the array. Documentation seems a tad thin on this.
Kinetics Screensavers

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2013
09:37 AM
Re: back button on array
Here are a left and right buttons on audio springboard which should increment items in an array of 5 items forward or backwards by one.
What is happening is both left and right buttons only increment one track forward, which is the same behavior as simply stopping the audio and starting it again. Does the format of the array matter? I ask because the titles on the springboard don't advance with the audio, it only shows the last items title. the array is like this:
I've seen arrays formated a bunch of ways, and since RokuJoel provided the code for the left/right buttons im looking somewhere else for the problem.
thanks
else if msg.isRemoteKeyPressed()
if msg.GetIndex() = 4 ' < LEFT
scr.ClearButtons()
if msg.isPlaybackPosition() then
spot = msg.GetIndex()
index = playlist[spot]
if index > 0 then index=index-1
if index=0 then index=playlist.count()-1
m.audio.SetNext(msg.GetIndex() -1)
end if
m.audio.Play()
scr.AddButton(2, "Pause")
scr.AddButton(4, "Stop")
scr.AddButton(5, "Done")
else if msg.GetIndex() = 5 ' > RIGHT
scr.ClearButtons()
if msg.isPlaybackPosition() then
spot = msg.GetIndex()
index = playlist[spot]
if index > 0 then index=index+1
if index=0 then index=playlist.count()+1
m.audio.SetNext(msg.GetIndex() +1)
end if
m.audio.Play()
scr.AddButton(2, "Pause")
scr.AddButton(4, "Stop")
scr.AddButton(5, "Done")
end if
What is happening is both left and right buttons only increment one track forward, which is the same behavior as simply stopping the audio and starting it again. Does the format of the array matter? I ask because the titles on the springboard don't advance with the audio, it only shows the last items title. the array is like this:
port = CreateObject("roMessagePort")
m.audio = CreateObject("roAudioPlayer")
m.audio.SetMessagePort(port)
item = CreateObject("roAssociativeArray")
item.Url = "http://www.xxx.com/roku/songs/dawn.mp3"
item.Artist = "xxx"
item.Title = "Dawn"
item.Album = "Alls Well That Ends Well"
item.HDPosterUrl = "pkg:/images/albumcover_hd.png"
item.SDPosterUrl = "pkg:/images/albumcover_sd.png"
item.StreamFormat = "mp3"
m.audio.AddContent(item)
item.Url = "http://www.xxx.com/roku/songs/nightfall.mp3"
item.Artist = "xxx"
item.Title = "Dusk"
item.Album = "Alls Well That Ends Well"
item.HDPosterUrl = "pkg:/images/albumcover_hd.png"
item.SDPosterUrl = "pkg:/images/albumcover_sd.png"
item.StreamFormat = "mp3"
m.audio.AddContent(item)
m.audio.SetLoop(true)
m.audio.SetNext(0)
I've seen arrays formated a bunch of ways, and since RokuJoel provided the code for the left/right buttons im looking somewhere else for the problem.
thanks
Kinetics Screensavers