问题
I have tried to disable autoplay with no success.
Here's my code:
<embed height="17" src="1GasolineSample.mp3" autoplay="false" type="audio/mpeg" width="60" controls="console">
Failed attempts:
- removing
autoplay
completely - changing
autoplay
toautostart
andAutoStart
- setting
autoplay
/autostart
/AutoStart
to zero - setting
autoplay
/autostart
/AutoStart
to one - setting
autoplay
/autostart
/AutoStart
to true - setting param name="AutoStart" value equal to 0
No changes in behavior occurred. Browser closing and refreshing made no difference. Any help would be greatly appreciated.
回答1:
Try to remove the:
autoplay="false"
This attribute makes the browser render this information and may replay it regardless.
If this does not work add the:
autoplay="false"
To you HTML 'source' tag.
Vote up if it help brother.
回答2:
Remove the autoplay attribute all together.
I suggest using the HTML5 AUDIO tag <audio>
that way you can include controls and other features. It's also a good idea to include other formats to make sure any browser can play it.
<audio controls="controls">Your browser does not support the <code>audio</code> element.
<source src="1GasolineSample.mp3" type="audio/mpeg">
<source src="1GasolineSample.ogg" type="audio/ogg">
<source src="1GasolineSample.wav" type="audio/wav">
</audio>
From MDN
Autoplay - A Boolean attribute; if specified (even if the value is "false"!), the audio will automatically begin playback as soon as it can do so, without waiting for the entire audio file to finish downloading.
回答3:
autoplay doesn't need a value... include or exclude the attribute...
this will play automatically:
<video src="source.mp4" autoplay />
this will not
<video src="source.mp4" />
回答4:
Instead of using:
<embed height="17" src="1GasolineSample.mp3" autoplay="false" type="audio/mpeg" width="60" controls="console">
use:
<audio controls src="1GasolineSample.mp3">
This will stop it from autoplaying.
回答5:
This will disable browser from autoplaying audio.
HTML
<audio type="audio/wav" id="audio" autoplay="false" autostart="false"></audio>
jQuery
$('#audio').attr("src","path_to_audio.wav");
$('#audio').play();
来源:https://stackoverflow.com/questions/42307689/disabling-autoplay-for-mp3