Multiple levels in internet radio via javascript

Nikolaj Hald Nielsen nhnfreespirit at gmail.com
Thu Nov 26 13:11:39 CET 2009


The scripted services support up to 4 levels.

When creating a script, there is an argument to specify how many
levels you want. For instance:

ScriptableServiceScript.call( this, "Librivox.org", 3, "Search for
books from Librivox", html, true );

The librivox script uses 3 levels. This means that in the
"onPopulating" callback, you will initially be asked to provide the
nodes for level 2 (the levels are 0 indexed.)

- Nikolaj

On Thu, Nov 26, 2009 at 5:37 AM, Pierre Dumuid <pmdumuid at gmail.com> wrote:
> 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
> _______________________________________________
> Amarok-devel mailing list
> Amarok-devel at kde.org
> https://mail.kde.org/mailman/listinfo/amarok-devel
>


More information about the Amarok-devel mailing list