2016-09-12 36 views
0

我正嘗試在Javascript上構建一個Swing Era自動點唱機。幾乎所有的工作除了'針'。我希望我不是唯一仍在使用乙烯基的人!只需說暫停按鈕應該能夠從音頻暫停的位置恢復,就像提起針並將其放在同一個位置一樣。它只能暫停。Javascript音頻暫停按鈕可以工作,但不會再次恢復

這裏是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? 
     } 
    } 
+1

''(playing = true)'< - 作業 – epascarello

+0

你可以給一個小提琴樣品。它是基於HTML5的音頻盒嗎?可能你可以檢查條件語句。 –

回答

0

退房這種說法

if(playing === true) 

而不是

if(playing = true) 
0

我知道了。我在這裏使用冗餘語言。答案是:

Jukebox.prototype.needle = function(){ 
    if (playing) { 
    this.tune.pause(); 
    playing = false; 
    } 
    else { 
    this.tune.play(); 
    playing = true; //After it is paused, it cannot play again?! Why? 
    }