Multiple levels in internet radio via javascript
Pierre Dumuid
pmdumuid at gmail.com
Thu Nov 26 05:37:36 CET 2009
Hi All,
I've been looking at some of the java script around that add radio
stations to the Internet Media source. I'd like to have a deeper tree
than two-leveled as per most of the scripts. I.E.
Australia Radio Stations
\- 1. By State
| \|-ACT
| | \|-Radio Station 1
| | |-Radio Station 2
| | |-Radio Station 3
| | |-...
| |-N.S.W.
| | \|-Radio Station 4
| | |-Radio Station 5
| | |-Radio Station 6
| | |-...
| |-Vic.
| |-S.A.
|- 2. Internet only Streams
| \|-Radio Station 7
| |-Radio Station 8
|- 3. Local ABC
|- 4. Network Stations
Reading through the code, I'm not sure if I can do this! (i.e. more than
1 depth)
From the numerous javascript samples around, I am guessing that
script.populate.connect( onPopulating );
links tells amarok to call the javascript function "onPopulating" to
populate the tree. Most implementations have something like:
function onPopulating( level, callbackData, filter )
{
if (level == 1) {
// Add the First level items
item = Amarok.StreamItem;
item.level = 1;
item.callbackData =
...
script.insertItem( item );
} else if (level == 0) {
for (..loop through source for children from callbackData..) {
item = Amarok.StreamItem;
item.level = 0;
...
script.insertItem( item );
}
}
So I'm guessing data is filled in is that amarok calls the onPopulate
with level=1 to get the first level, and then if callbackData exists (or
not??), it'll call onPopulate again with the callbackData, and with
level=0 to get the leaf nodes. If this is the way it works, if the
level of a leaf of a leaf is -1? Should the level increase with depth?
I wasn't sure if I'm on the right path, could someone who know's the
code a little bit enlighten me?
Pierre
More information about the Amarok-devel
mailing list