How to play multiple sound files on one Web Page? (on click best practice)

前端 未结 1 1794
醉酒成梦
醉酒成梦 2021-01-18 09:39

I have a page where there is a list of vocabularies. I have a TTS for each vocabulary. The current approach that I am using is to include an mp3 flash player for each vocabu

1条回答
  •  长情又很酷
    2021-01-18 10:10

    You can use the tag (HTML5) and you can control it when to load the files.
    It is supported in most of the browsers like Google Chrome, Firefox, Opera...

    It has two ways to set the link:

    Way 1

    
    

    Way 2

    
    

    Attributes

    • Put controls="controls" if you want it to display the audio player.
    • Put loop="loop" if you want it to loop the audio.
    • Put autoplay="autoplay" if you want it to play the audio by itself.
    • Put preload="preload" if you want it to preload it.

    JavaScript Controlling

    You can also control it using JavaScript.

    To play it: document.getElementById("YOUR AUDIO TAG").play()
    To pause it: document.getElementById("YOUR AUDIO TAG").pause()


    Read more

    • http://w3schools.com/html5/tag_audio.asp

    0 讨论(0)
提交回复
热议问题