[英]How to autoplay one audio tag when the page has more than 20 audio tags loaded dynamically?
我一直在尝试制作一个系统,其中必须在不同的时间播放从 MySQL 数据库加载的播放列表
例如:如果是早上 8 点,有一首歌需要播放,当时钟敲响 9 点时它应该自动改变
<tr class="hidden" >
<td start="'.strtotime($time_prev).'" finish="'.strtotime($time_next).'" style="padding:20px;">
<div class="row">
<div class="col-md-4 col-sm-12">
Date: <strong>'.date("d M Y l",$current_date).'</strong>
<p>Running from : '.$time_prev.' - '.$time_next.'</p>
</div>
<div class="col-md-4 col-sm-12">
</div>
<div class="col-md-4 col-sm-12">
<p>
<audio class="play_audio" controls loop>
<source src="'.$result3["planet_mantra"].'" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>
</p>
</div>
</div
</td>
</tr>
这是 PHP 代码,当时间戳位于开始时间和结束时间之间时,我删除了隐藏的 class。 但是当当前 div 可见时我应该如何播放音频。
因此,在同一步骤中,当您删除hidden
的 class 时,您可以像这样将autoplay
属性添加到您的音频标签中<audio controls autoplay> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
<audio controls autoplay> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
希望有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.