html5中為audio標(biāo)簽增加停止按鈕動(dòng)作實(shí)現(xiàn)方法

字號(hào):


    在html 5中的audio標(biāo)簽中,只有暫停按鈕,但沒有停止按鈕,其實(shí)為其增加也不麻煩,方法如下:
    代碼如下:
    HTMLAudioElement.prototype.stop = function()
    {
    this.pause();
    this.currentTime = 0.0;
    }
    其實(shí)很簡(jiǎn)單,就是先暫停,然后時(shí)間歸0;
    調(diào)用方法:
    代碼如下:
    var aud = new Audio();
    aud.src = '特殊他.ogg';
    aud.play();
    aud.stop();
    上面代碼可以在chrome,opera下跑,但firefox 17不行