如何在网站上自动播放Mp3

时间:2018-06-06 19:20:09

标签: mp3 playback auto

我需要在HTML网站上设置自动播放Mp3音频。我不确定应该添加哪个代码或类。请帮忙。这是我的编码。

            <div id="jp_container_2" class="jp-audio" role="application" aria-label="media player">
                <div class="jp-type-playlist">
                    <div class="jp-playlist">
                        <ul>
                            <li>&nbsp;</li>
                        </ul>
                    </div>
                    <div class="jp-gui jp-interface">
                        <span class="jp-stop wm-bgcolor"><i class="flaticon-power"></i></span>
                        <div id="current-track1" class="song-title">Song Name is here</div>
                        <div class="jp-controls">
                            <span class="jp-shuffle"><i class="flaticon-arrows-2"></i></span>
                            <span class="wm-bgcolor-one jp-previous"><i class="flaticon-arrows-1"></i></span>
                            <span class="jp-play"><i class="fa fa-pause"></i> <i class="fa fa-play"></i></span>
                            <span class="wm-bgcolor-one jp-next"><i class="flaticon-arrows-1"></i></span>
                            <span class="jp-repeat"><i class="flaticon-arrows-3"></i></span>
                        </div>
                        <div class="wm-player-wrap">
                            <div class="jp-progress">
                                <div class="jp-seek-bar">
                                    <div class="jp-play-bar"></div>
                                </div>
                            </div>
                            <div class="jp-volume-controls">
                                <span class="jp-mute"><i class="fa fa-volume-up"></i> <i class="fa fa-volume-off"></i></span>
                                <div class="jp-volume-bar">
                                    <div class="jp-volume-bar-value"></div>
                                </div>
                            </div>
                        </div>
                        <a href="#" class="wm-playlist-btn"><i class="flaticon-music-1"></i></a>
                    </div>
                </div>
            </div>

1 个答案:

答案 0 :(得分:0)

只需使用音频标签:

<audio src="track.mp3" autoplay></audio>

请注意,自动播放受浏览器政策的约束。例如,移动浏览器通常不允许自动播放。