Skip to main content
chenjil43641795
Legend
October 15, 2020
Answered

(ANCC,HTML5)How to detect browser support(video,audio).

  • October 15, 2020
  • 3 replies
  • 578 views

video,Ogg,MPEG 4,WebM

video,Ogg,MP3,Wav。

Different browsers use different types.

Hope to detect the type supported by the current browser,
Automatic playback to this type of file.

How the code is written in ANcc html5.

For example:  

<audio controls="controls">
  <source src="song.ogg" type="audio/ogg">
  <source src="song.mp3" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>

 

    This topic has been closed for replies.
    Correct answer kglad

    you can use the canPlayType of a document element but the audio tag allows the user's browser to select the first supported type.

    3 replies

    kglad
    Community Expert
    Community Expert
    October 17, 2020

    you're welcome 

    Legend
    October 16, 2020

    All modern browsers support MP3 and MP4. Just use those and don't worry about it.

     

    https://caniuse.com/mp3

    https://caniuse.com/mpeg4

     

    chenjil43641795
    Legend
    October 17, 2020

    Thank you for your answer.

     

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    October 16, 2020

    you can use the canPlayType of a document element but the audio tag allows the user's browser to select the first supported type.

    chenjil43641795
    Legend
    October 17, 2020

    Thank you, it's being used to solve the problem.

    Now I can automatically switch to a supported format.

    3Q.

     

     

    edge 

    ie11

    google chrome