+ 2
What is problem in this code
<audio autoplay> <source src="https://raw.githubusercontent.com/debansu4/www.data.transfer.com/main/Ishita___Rishi_Panda(256k).mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
5 Antwoorden
+ 8
browsers don't autoplay because it is annoying. add controls so that the user can start and stop the audio.
+ 2
most browsers do NOT ALLOW autoplay.
+ 1
Not all browsers use autoplay.You can add tothe play and pause button or the next and previous button to be controlled manually instead of automatically
+ 1
Well, Debansu Das , your code is syntactically correct and completely valid.
However, there are a few problems in your audio file source (in addition to the issue regarding the autoplay which I shall come to later). GitHub raw files are not optimised for direct media streaming.
Some browsers may block cross-domain autoplay when CORS headers are missing. Also, if the file is not publicly accessible with correct MIME type,it will not load properly.
That said, let us come to how modern browsers handle autoplay. They block audio autoplay UNLESS the audio is MUTED, the user has INTERRACTED with the page or the user has previously given autoplay PERMISSION to your site.
What you can do is keep the audio initially muted and then play it after a user interaction like keypress or click.
You might check out a few of my codes that involve audio playback:
https://sololearn.com/compiler-playground/WGZOtO1YcX5Z/?ref=app
https://sololearn.com/compiler-playground/W86sDu3d61DG/?ref=app
0
Then how to use autoplay