【问题标题】:How can one reset an HTMLAudioElement's current playback position to 0?如何将 HTMLAudioElement 的当前播放位置重置为 0?
【发布时间】:2012-09-01 09:57:35
【问题描述】:

查看此演示页面:http://www.phon.ucl.ac.uk/home/mark/audio/play10.htm

快速连续单击两次Play Sound 按钮。因为在您再次按下按钮时它还没有完成第一次播放,所以没有任何反应,并且单击似乎被忽略了。怎么能重新编码让它停止当前播放,将播放位置重置到声音的最开始,并在每次点击Play Sound按钮时重新启动它?

【问题讨论】:

标签: javascript audio html5-video html5-audio


【解决方案1】:

你可以把它改成这样的

var thissound=document.getElementById('audioElemID');
thissound.currentTime=0;
thissound.play();

【讨论】:

  • 似乎不起作用..我做错了什么吗? (#FIXME 的 grep)jsbin.com/izoleg/1/edit
  • 实际上,当我在链接页面的控制台中修改EvalSound 函数时,它可以工作。但无论出于何种原因,它在我的垃圾箱上都不起作用……有什么线索吗?
【解决方案2】:
thissound=document.getElementById(soundobj);
thissound.currentTime = 0;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-30
    • 1970-01-01
    相关资源
    最近更新 更多