<script>
let mySong = new
Audio("_Dard_Dilo_Ke_Full_Song_(Audio)__Himesh_Reshammiya,_Yo_Yo_Honey_Singh(128k).m4a");
console.log((mySong.duration)/60);
</script>这首歌是4.24分钟,但当我控制台日志时,同一首歌的持续时间为4.40分钟。如何处理这个问题
发布于 2022-01-16 11:26:22
不知道你为什么要把它除以60 (你想把它转换成分钟)。没有必要这样做。您只需通过以下方式获得持续时间
`var obj = document.createElement('video');
console.log(obj.duration); `或者如果您想更新时间:
duration = parseInt( audio.duration ),
currentTime = parseInt( audio.currentTime ),
timeLeft = duration - currentTime,您可以将其转换为分钟和秒,如下所示:
second = timeLeft % 60;
mintues = Math.floor( timeLeft / 60 ) % 60;https://stackoverflow.com/questions/70729145
复制相似问题