简体   繁体   English

自动播放WordPress音频播放列表(MediaElement.js)

[英]Autoplay WordPress Audio Playlist (MediaElement.js)

WordPress does not offer an 'autoplay' option for the Audio playlists like they do single audio embeds. WordPress不会像音频嵌入一样为音频播放列表提供“自动播放”选项。

Since WordPress is using MediaElement.js, there should be a work-around, yes? 由于WordPress使用MediaElement.js,因此应该有一种解决方法,是吗?

I've searched around plenty and have not found a workable answer. 我搜索了很多内容,但没有找到可行的答案。

For example, Autoplay MediaElementPlayer 例如, 自动播放MediaElementPlayer

Lots of good variations there, but none seem to work with the WordPress playlist player element. 那里有很多不错的变体,但似乎没有一个可以与WordPress播放列表播放器元素一起使用。

My lack of Javascript and jQuery is limited, but the CSS unique selector I've found on the playlist is 我缺乏Javascript和jQuery是有限的,但是我在播放列表中找到的CSS唯一选择器是

div.mejs-button.mejs-playpause-button.mejs-play > button

Therefore I was hoping a solution such as 因此,我希望有一个解决方案,例如

$(document).ready(function() {
$("div.mejs-button.mejs-playpause-button.mejs-play > button").trigger('click');
});

at the top of the single-page template I have my player on - would work, but no avail. 在单页模板的顶部,我可以播放我的播放器-可以,但无济于事。

Anyone know of a suitable work around for this? 有人知道合适的解决方法吗? Since WP does not inherently support it, I'm assuming a javascript or jQuery solution is required. 由于WP本质上不支持它,因此我假设需要javascript或jQuery解决方案。 TY! TY!

edit: 编辑:

Here is the play control: 这是播放控件:

<div class="mejs-controls"><div class="mejs-button mejs-playpause-button mejs-play">
<button type="button" aria-controls="mep_0" title="Play" aria-label="Play"></button></div>

I was close. 我离得很近。

<script type="text/javascript">
$(window).bind("load", function() {
$("div.mejs-button.mejs-playpause-button.mejs-play > button").trigger('click');
});
</script>

The solution was to use $(window).bind("load", function() instead of $(document).ready(function() so that the script is run only after the page has loaded. 解决方案是使用$(window).bind("load", function()代替$(document).ready(function()以便仅在页面加载后运行脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM