I'm using jplayer playlist with autoplay. Playlist is shown, songs are playing,it is ok. But I want to get current songs name when jplayer changes to next song. I couldnt find any documentation for this.
How can I get the current song name when song is changed?
Here is jplayer playlist sample code.
var myPlaylist = new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_N",
cssSelectorAncestor: "#jp_container_N"
}, [
{
title:"Song 1",
artist:"Artist 1",
mp3:"http://www.example.com/audio/song1.mp3",
oga:"http://www.example.com/audio/song1.ogg"
},
{
title:"Song 2",
artist:"Artist 2",
mp3:"http://www.example.com/audio/song2.mp3",
oga:"http://www.example.com/audio/song2.ogg"
}
], {
playlistOptions: {
autoPlay: true,
enableRemoveControls: true
},
swfPath: "/js",
supplied: "ogv, m4v, oga, mp3",
smoothPlayBar: true,
keyEnabled: true,
audioFullScreen: false // Allows the audio poster to go full screen via keyboard
});
You are using the playlist addon of jPlayer, from the docs:
The third parameter is an object to define the jPlayer options and jPlayerPlaylist options. This object is passed to jPlayer (...)
And here you can see the list of available events of jPlayer. The one useful for your question is:
$.jPlayer.event.play * Occurs when the media is played.
So, in your code, you could add a last parameter to override the play
event of jPlayer. There you can access the title of the song being played at that moment:
play: function(e) {
console.log(e.jPlayer.status.media.title);
}