Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
squirreltown
Roku Guru

Re: Array index

Great, two questions about that -
1)
status message "end of Play" says its depreciated - does that mean i shouldn't use it?
if so thats fine, i can increment the index each time a track starts instead.

2) After passing the index variable to the slideshow if I have something like this to increment the variable in the message loop"

if type (msg) = "roAudioPlayerEvent"
if msg.isStatusMessage() then
if msg.getmessage() = "start of play"
index = index+1

that should do it right?

thanks again for your time & help.
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: Array index

Well i tried that and it isn't going to work. The slideshows already have several variables and adding a return function to them causes type mismatch errors which i will not be able to diagnose, and therefore fix. It took a long time to get them working properly.

I still think this will work for me:

m.song = item["Num"].ToInt()  'wrong syntax


from array
item=[
{
Url: "http://www.xxx.com/roku/songs/song.mp3",
....other parameters
Num:"0"
},
{
.....other tracks
}]


I just need to know the right syntax for that, i cant figure it out.

edit - I've confirmed this will work, by making the array a global variable its alive on re-launch of the springboard, it just need to convert that Num variable to an Integer, given its context as an array within an array, so actually it needs to be Item.X.Num.X as in known, unknown, known, unknown.
Kinetics Screensavers
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: Array index

Is there a reason for assigning the num attributes string values in the first place? Why not just use integers from the start and eliminate the need to convert?
{ num: 0 }
0 Kudos
squirreltown
Roku Guru

Re: Array index

"RokuChris" wrote:
Is there a reason for assigning the num attributes string values in the first place? Why not just use integers from the start and eliminate the need to convert?
{ num: 0 }


Thats a really good question, i had thought I couldn't do that, but since you said that I just tried it again and that part worked fine, so you are right. The problem is this silly "non-numeric index" error that i am getting which i am now thinking is because I'm trying to get the value "num" which is now an integer (thank you) which is in the sub-array.
So I know the array name, dont know the asso-array index , know the key, and need the key value.

The syntax of that is beyond me and I'm convinced its the last piece to this.

yep thats it, i just tried it with a known sub-array and it worked
m.song = m.item[1]["Num"]
The issue is i wont know what [1] is.
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: Array index

So for anyone else following this I will recap - i am opening an audio springboard with the music already playing.

The playlist is an array of arrays. its a live variable when the springboard opens

I need to ask the array what is the index of the current associate array, the one that the currently playing audio is coming from.
the array is m.item

So, m.song = m.item [ ? ]

thanks
Kinetics Screensavers
0 Kudos
RokuMarkn
Visitor

Re: Array index

The array doesn't know anything about what song is playing, it's just a list of things. There's no "current index" in an array. You already have the index of the current song, your "m.song" variable (at least it looked correct in one version of the code you posted). You should set this variable when you get the IsListItemSelected message from the audio player. In later postings you seem to be trying to set m.song to be an item in the array rather than the array index. Those are two different things.

--Mark
0 Kudos
squirreltown
Roku Guru

Re: Array index

Thanks Mark. Good to know there is no array index, so I'm not up a tree putting my own in and trying to find it, it Looks like destruk has helped me do that. The problem I've had is that the audioplayer index is fluid, it starts at zero from the first track you play, even if thats the third item in the array which makes syncing it with the screen info trouble, but i may have it licked today.
Kinetics Screensavers
0 Kudos
RokuMarkn
Visitor

Re: Array index

You're talking about the index that you get from the isListItemSelected event, right? That should be an index into the content list array.

--Mark
0 Kudos
squirreltown
Roku Guru

Re: Array index

Yes i just printed it and of course you are right. I dont know what i was doing yesterday . I'm just trying to sync audio and screen info, when you choose a track and when you re-open the springboard after being somewhere else. Its a three day problem so far. It seems like it should be easier than this but I'll get it eventually.
Kinetics Screensavers
0 Kudos
m1sh1k0
Newbie

Re: Array index

function getIndex(arr, value)
i = 0
  for each item in arr
     if item = value
       return i
      end if 
   i++
 end for
return invalid
end function
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.