首页 > 解决方案 > “currentTime”音频属性不适用于我的安卓手机

问题描述

“currentTime”音频属性不适用于我的安卓手机。当我使用句子“aud.currentTime=30”时,这会返回到位置0。示例:

<html> 
<body> 

<button onclick="getCurTime()" type="button">Get current time position</button>
<button onclick="setCurTime()" type="button">Set time position to 30 seconds</button><br> <br><br>
<audio d="myAudio" controls>
  <source src="https://suarezfco65.github.io/amobiodanza/IBFC21 - 18 - OST Metello (Morricone, Ennio) - Metello.mp3" type="audio/mpeg">
  Your browser does not support HTML5 audio.
</audio>
<script>
var aud = document.getElementById("myAudio");
alert("Inicio");

function getCurTime() { 
alert(aud.currentTime);
} 

function setCurTime() { 
  aud.currentTime=30;
} 
</script>

</body> 
</html>

标签: javascriptandroidhtmldomaudio

解决方案


推荐阅读