gpt4 book ai didi

javascript - 在 00 :00 format? 中获取音频时间更新

转载 作者:行者123 更新时间:2023-11-30 14:16:33 26 4
gpt4 key购买 nike

我在我的项目中使用 html5 音频标签。一切正常。

我需要使用 timeupdate 并以这种格式获取已经过去的分钟值:00:00

目前我只能用我的代码获取 0:00 的值:

这是我的代码:

$(audio).bind('timeupdate', function(){
var percent = audio.currentTime/ audio.duration * 100;

/////Passed time////
var mins = Math.floor(audio.currentTime / 60);
var secs = Math.floor(audio.currentTime % 60);
if (secs < 10) {
secs = '0' + String(secs);
}

$('.Audio_passedTime').text(mins + ':' + secs);
});

还有一个工作 fiddle :http://jsfiddle.net/8cpwv2mf/

有人可以就此问题提出建议吗?

提前致谢。

最佳答案

您可以使用与 mins 相同的结构,如下所示:

$(audio).bind('timeupdate', function() {
var percent = audio.currentTime/ audio.duration * 100;

/////Passed time////
var mins = Math.floor(audio.currentTime / 60);
if (mins < 10) {
mins = '0' + String(mins);
}
var secs = Math.floor(audio.currentTime % 60);
if (secs < 10) {
secs = '0' + String(secs);
}

$('.Audio_passedTime').text(mins + ':' + secs);

关于javascript - 在 00 :00 format? 中获取音频时间更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53484110/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com