the code is as follows
$(document).ready(function () {
var audioElement = document.createElement("audio");
audioElement.setAttribute("src", $(".active-song").attr("data-src"));
var tl = new TimelineMax();
tl.to(".player__albumImg", 3, {
rotation: "360deg",
repeat: -1,
ease: Power0.easeNone
}, "-=0.2");
tl.pause();
//
if ($(".player").hasClass("play")) {
$(".player").removeClass("play");
audioElement.pause();
TweenMax.to(".player__albumImg", 0.2, {
scale: 1,
ease: Power0.easeNone
})
tl.pause();
} else {
$(".player").addClass("play");
audioElement.play();
TweenMax.to(".player__albumImg", 0.2, {
scale: 1.1,
ease: Power0.easeNone
})
tl.resume();
}
$(".player__play").click(function () {
if ($(".player").hasClass("play")) {
$(".player").removeClass("play");
audioElement.pause();
TweenMax.to(".player__albumImg", 0.2, {
scale: 1,
ease: Power0.easeNone
})
tl.pause();
} else {
$(".player").addClass("play");
audioElement.play();
TweenMax.to(".player__albumImg", 0.2, {
scale: 1.1,
ease: Power0.easeNone
})
tl.resume();
}
})
errors will be reported in Google browser
DOMException: play () failed because the user didn"t interact with the document first