我正在尝试在Javascript上构建Swing Era自动点唱机。除了“针”,几乎所有东西都起作用。我希望我不是唯一仍然使用乙烯基的人!只需说一下暂停按钮就应该能够从音频被暂停的位置恢复,就像提起针并将其放在同一位置一样。到目前为止,它只能暂停。
这是JS代码,或者我认为是相关的摘录:
var playtext = $("div#play").text()
var playing = false
function Jukebox(){
this.tune = $("audio")[0];
Jukebox.prototype.play = function(){
this.tune.play();
playing = true;
}
Jukebox.prototype.pause = function(){
this.tune.pause(); //Apparently, pause is a built-in function?!
playing = false;
}
Jukebox.prototype.needle = function(){
if (playing = true) {
this.tune.pause();
playing = false;
}
if (playing = false) {
this.tune.play();
playing = true; //After it is paused, it cannot play again?! Why?
}
}
最佳答案
查看此声明
if(playing === true)
而不是
if(playing = true)
关于javascript - Javascript音频暂停按钮有效,但不会再次恢复,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39453062/