Back to my page

Developer Blog



Use the Netvibes podcast player from your UWA widget

Not everyone knows it, but you can access and control the internal podcast player using UWA - and we’ll show you how in this very article.

The example used here is the excellent Web Radio Player widget, built by Maurice Svay and which lets you play audio streams in MP3 format from the renown ShoutCast service.

Web Radio Player, as seen using Opera

When installed in Netvibes, it uses the Netvibes podcast player, which is also used when you listen to an audio stream from a podcast feed that you added to your Netvibes page. As advertised, on platforms other than Netvibes, the widget will let you play radios with your favorite desktop player: Winamp, Windows Media Player, iTunes, etc. - basically any player that supports .mp3 files (or .pls files, since this widget cleverly parses them to send the .mp3 to the podcast player). So your widget is not limited to Netvibes!

Obviously we won’t dissect the whole source code here, that would require and go directly to the code related to the podcast player, which consists simply of a call to one method:

AudioPlayer.play(streamURL, 'Name of the stream');

This method triggers the launch of the podcast player. To be a little cleaner, the code first check for the presence of the AudioPlayer.play method before even launching the Ajax request that fetch the steam and launching AudioPlayer.play. Here is an overview of how Maurice does it:

Radio.parseList = function(text){
  // code that fetches and displays
  // every station of the PLS file as a link
  if (AudioPlayer.play){
    Radio.loadStation(this.href);
    return false;
    }
  // HTML generation
  }

Radio.loadStation = function(url){
  UWA.Data.getText(url, Radio.playStation);
  }
Radio.playStation = function(text){
  // Data handling
  AudioPlayer.play(playableStream, 'Web Radio Player');
  }

play is not the only method available! AudioPlayer also gives you access to pause and stop, if you ever want to fully control the podcast player from within your widget. Learn all about it on the documentation page for the AudioPlayer objet!

Tags: , , ,

8 Responses to “Use the Netvibes podcast player from your UWA widget”

  1. Frantz Gauthier Says:

    Really nice but listening an mp3 ’stream’ (like shoutcast) with a flash application could be harmful cause Flash Player considers the ’stream’ as a never ending mp3 file and inflate memory usage.

    I recommend reading this page for more information : http://www.draftlight.net/dnex/mp3player/minicaster/explained.php

  2. George Says:

    some body explain how to listen to the webradio…pls email me.Thankx

  3. Arnaud M Says:

    Hello,
    very great idea of widget but on my netvibes the AudioPlayer doesn’t work (for the radios and for the podcasts).

    Thanks.

    regards

  4. Xavier Says:

    George: if the widget doesn’t work for you, please contact the author. There is a feedback form on the widget’s Ecosystem page once you’re logged in, or a classic comment form.

    Arnaud: same for you I guess. Please contact the author directly. However, since the widget relies on external plugins, it might not work 100% for everyone - your mileage may vary.

  5. resim Says:

    Hello,
    Thank you I love this kind of JavaScript-APIs. Maybe I can use it in my next web design projects.

  6. resim Says:

    Thanks for the code

  7. komik videolar Says:

    i did not understand webradio :(

  8. Resimcim Says:

    can i use my site this code? really good? Thanks for the code.

Leave a Reply


Business

Click here if you want to know more about how netvibes can help you widgetize your brand and connect to your audience.

Developers

Click here to learn about netvibes open widget platform and how you can create cool widgets for your service or your application that run everywhere.

Community

Click here to know how to join the netvibes community, get involved and help us translate and create a global directory of widgets for netvibes

Media

Click here to access informations about the company, our latest press release, our logos and media kit