Frage

I'm trying to use Yahoo web player for playing .mp3 files. The player automatically recognizes tracks when page is initially loaded. Is there a way to add more tracks through api calls later on ?

http://developer.yahoo.com/webplayer/

War es hilfreich?

Lösung

No wonder I can't find any api for webplayer:

1) The yahoo webplayer has same api as the older yahoo media player (its just rebranded as webplayer): http://mediaplayer.yahoo.com/api/

2) To control the webplayer through javascript we can use the YAHOO.MediaPlayer object that is created once the player is setup. for example if the node with id 'playlist' has our dynamically loaded mp3 file links:

<div id="playlist">
</div>
<script type="text/javascript" src="http://webplayer.yahooapis.com/player.js"></script>
<script>
/** On Yahoo Media API Ready **/
YAHOO.MediaPlayer.onAPIReady.subscribe(function(){
  console.log("player ready");
});

// addFiles is the function that can be called once the playlist is populated any time
function addFiles()
{
    document.getElementById('playlist').innerHTML = '<a href="http://mediaplayer.yahoo.com/example3.mp3" style="display:none;"> linky blinky </a>';
    YAHOO.MediaPlayer.addTracks(document.getElementById('playlist'), 0, true);
    YAHOO.MediaPlayer.play();
}
</script>

3) Related questions:

YAHOO webplayer (MediaPlayer) and ajax

Processing dynamic MP3 URL using Yahoo Media Player

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top