(originally posted on hp developer center forums: https://developer.palm.com/distribut...p?f=11&t=16783 , not trying to spam all over the place just wanted to try to reach as many people as possible for help.)


Hey everyone,

I was wondering how to create a ListSelector widget that programatically populates its contents with audio files found in a certain directory (or included in app).

Basically here is some context: I want to have a Preference screen where the user can choose a sound, kind of like if you were to change your ringtone through the sound settings in webos, except instead of a new scene with a list of the files and so on there is just a simple drop down list that is populated and you choose one. When the user opens preferences the first time, a default sound is chosen (that I have included with my app and set as a cookie), but if the list is tapped it opens up to some more options.

Additionally, I would like users to be able to add their own sounds to this list (although this is more of a long term goal). So the list would populate with the default sounds, and have an option at the bottom of the list to "Pick custom sound" or something of the sort. This could also be done differently, like how picking a new ringtone is done by webos (with the icon in the bottom corner to add a new one). For now I just want to have the list programmatically populate from eithera directory like /internal/media/sounds or something like that or sounds included within my app (although I'd prefer the first, since I don't really have the means to create any sound effects and don't want to include copyrighted material).

I realize I probably need to use the FilePicker class in conjuction with the ListSelector, but for my ListSelector, how do I create the model so that it is not just a hard coded json model.

I'm new to web programming and Mojo, so I'm probably in way over my head here, but any help would be greatly appreciated.

Also, I'm aiming for 1.4.5 (Mojo) compatibility, so no Enyo for me.

Thanks, and if anything needs clearing up please don't hesitate to ask.