Heim  >  Artikel  >  Web-Frontend  >  html5中为audio标签增加停止按钮动作实现方法_html5教程技巧

html5中为audio标签增加停止按钮动作实现方法_html5教程技巧

WBOY
WBOYOriginal
2016-05-16 15:50:421870Durchsuche

在html 5中的audio标签中,只有暂停按钮,但没有停止按钮,其实为其增加也不麻烦,方法如下:

复制代码
代码如下:

HTMLAudioElement.prototype.stop = function()
{
this.pause();
this.currentTime = 0.0;
}

其实很简单,就是先暂停,然后时间归0;
调用方法

复制代码
代码如下:

var aud = new Audio();
aud.src = '特殊他.ogg';
aud.play();
aud.stop();

上面代码可以在chrome,opera下跑,但firefox 17不行
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn