Skip to content

Instantly share code, notes, and snippets.

@vineettalwar
Last active March 12, 2019 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vineettalwar/ccefd839f431e9430f66344950a8364d to your computer and use it in GitHub Desktop.
Save vineettalwar/ccefd839f431e9430f66344950a8364d to your computer and use it in GitHub Desktop.
player on ended event
// event on play
player.$node.on('play', function(e){
updateDisplay();
//stop play other media
$('.app-body video, .app-body audio').each(function() {
$(this)[0].pause();
});
});
player.$node.on('ended', function(e){
var track = player.mepGetCurrentTrack();
var ctid = track.id;
var nid = getNextItem(ctid);
getItem(nid, 'fm_genre').done(function(obj){
if(obj.status === 'success'){
console.log (obj);
addToPlay(obj.tracks, true);
}
});
});
function getNextItem(id){
return $.ajax({
type : "post",
dataType : "json",
url : ajax.ajax_url,
data : {action: "ajax_next_music", id : id, nonce: ajax.nonce},
success: function(reply) {
console.log('reply is' + reply)
alert (reply.name)
return reply;
}
});
}
function getItem(id, type){
return $.ajax({
type : "post",
dataType : "json",
url : ajax.ajax_url,
data : {action: "ajax_music", id : id, type: type, nonce: ajax.nonce}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment