<!DOCTYPE HTML>
<html>

<body>

    <!-- <audio id="auto" controls="controls">
        <source src="voice.ogg" type="audio/ogg">
        <source src="voice.mp3" type="audio/mpeg" >
        <embed height="100" width="100" src="voice.mp3" />
    </audio> -->

<!-- <audio id="auto" src="voice.mp3" ></audio>
<button onclick="myplay()">Play the sound</button> -->

<!-- <iframe allow="autoplay" src="voice.mp3"></iframe>
 -->

<!-- <audio id="music" src="voice.mp3"></audio> -->
<audio id="music">
    <source src="voice.mp3" type="audio/mpeg">
</audio>
<button id="musicImg" onclick="myplay()" alt="user">play</button>

</body>
<script>

        window.onload = function(){ 
        var audio = document.getElementById('music');
        // audio.pause();//打开页面时无音乐
}
        function myplay() {
        var audio = document.getElementById('music');
        if (audio.paused) {
            audio.play();
        document.getElementById('musicImg');
        }else{
        audio.currentTime = 0;//音乐从头播放
        document.getElementById('musicImg');
    }
}
</script>
<!-- <script>
function myplay(){
    document.getElementById("auto").play()
}
</script>> -->

<!-- <script>
    var promise = document.getElementById('auto');
        if (promise !== undefined) {
            promise.then(_ => {
                // Autoplay started!
                promise.play()
            }).catch(error => {
                // Autoplay was prevented.
                // Show a "Play" button so that user can start playback.
                alert('click play');
                // <input type='button' name='clickplay' onclick="promise.play()">
                <button onclick="promise.play()">play</button>
                
            });
        }
</script> -->

</html>