var audio = new Audio("http://eniz.eu/wp-content/uploads/2021/01/Mozart-Lacrimosa.mp3"); jQuery('#play-pause-button').on("click",function(){ if(jQuery(this).hasClass('fa-play')) { jQuery(this).removeClass('fa-play'); jQuery(this).addClass('fa-pause'); audio.play(); } else { jQuery(this).removeClass('fa-pause'); jQuery(this).addClass('fa-play'); audio.pause(); } }); audio.onended = function() { jQuery("#play-pause-button").removeClass('fa-pause'); jQuery("#play-pause-button").addClass('fa-play'); };

EGO ADSUM