I have a list of audio files which comes from database. They start playing after clicking on the row. Now I want to automatically play the first audio file after page load. Everything is implemented well but Jquery Player is not initializing or any other problem with this. Can any body please help me about the same.
function playAudioFile(objid,title,filePath)
{
speaker_id = "speaker_"+objid;
rowid = "rowid_"+objid;
$('.datagridtable tr').removeClass('current_playing');
$('.black_speaker').removeClass('black_speaker');
$('#'+rowid).addClass("current_playing");
$('#'+speaker_id).addClass("black_speaker");
$('#jquery_jplayer').jPlayer('setFile', filePath).jPlayer('play');
$('#jplayer_playlist ul li').html(title);
showPauseBtn();
}
$(document).ready(function() {
playAudioFile('12','abasdfasdf','pathtofile')
});
a) FileBug is not giving any error.
b) I am sure the problem is with jplayer initialization but dont know how to tackle it.
This is the demo url http://webcartz.stagetesting.com/playlist
Thanks
You’ve put
playAudioFile();inside$(document).ready()this is the problem because the player is not yet ready and can’t fulfill your request.There doesn’t seem to be an autoplay function in the docs but according to http://jplayer.org/latest/developer-guide/#jPlayer-constructor-event-handlers what you need to do is use the
readyevent.This is probably in player.js