【问题标题】:Jplayer connected/bind to mediaelementJplayer 连接/绑定到 mediaelement
【发布时间】:2017-09-04 07:37:21
【问题描述】:

我正在尝试将我网站上的 jplayer 绑定到在我的网站上播放音乐的 mediaelement player(wordpress)。

我已经做了一些事情,但我错过了一些东西。在functions.php文件中我添加了

//Enqueue scripts
function register_scripts() {
      wp_enqueue_script('jplayer',get_template_directory_uri().'/jplayer/jplayer.min.js',null,'1',false);

}
add_action('wp_enqueue_scripts','register_scripts');

然后我在标题中添加了

<div id="WM" class="jp-jplayer"></div>
<div id="jp_container_1" class="jp-audio" role="application" aria-label="media player">
    <div class="jp-type-single">
        <div class="jp-gui jp-interface">
            <div class="jp-controls-holder" style="width:100px">
                <div class="jp-controls" style="float:left;">
                    <button class="jp-play" role="button" tabindex="0" style="padding:0;">p</button>
                    <button class="jp-stop" role="button" tabindex="0" style="padding:0;">s</button>
                </div>
                <div class="jp-current-time" role="timer" aria-label="time">&nbsp;</div>
            </div>
        </div>
    </div

然后我在页脚中添加了

<script>
jQuery(document).ready(function() {
    jQuery("#WM").jPlayer({
        ready: function(){
            jQuery(this).jPlayer("setMedia", {
                mp3: "https://example.com/mymp.mp3"
            });
        },
    });

});
</script>

现在这是其中的一部分,我正在努力解决。 Jplayer 需要在我的网站上与 mediaelement 播放器一起播放,因为 jplayer 包含带有音频水印的文件,因此它将播放通过 mediaelement 播放的我的音乐(我的主题支持它)。所以我在页脚中添加的代码是:

<script>
            // click on play button

            jQuery('.home, .page-id-53, .page-id-29 ,.tax-download_tag, .tax-download_category, .search-results,.tax-download_tempo,.tax-download-artist').find('.mejs-button.mejs-playpause-button').on('click', function () {

jQuery(window).load(function() {
                      setTimeout( function(){

                        jQuery("#WM").jPlayer("volume", 1);
                        jQuery("#WM").jPlayer("play", 0);
                       }, 1000 );
                    });

                    jQuery(document).on('click', '.mejs-play > button', function() {

 </script>

所以由于某种原因,当我点击播放按钮(mediaelement)时,jplayer 没有播放该文件我想我错过了一些东西,但不知道是什么,如果有人知道当我点击播放按钮时该怎么做才能播放它,但是当我暂停并再次播放时,它应该从头开始播放。

谢谢

【问题讨论】:

    标签: wordpress mediaelement.js jplayer


    【解决方案1】:

    假设这是代码的开始

    <script>
                // click on play button
    
                jQuery('.home, .page-id-53, .page-id-29 ,.tax-download_tag, .tax-download_category, .search-results,.tax-download_tempo,.tax-download-artist').find('.mejs-button.mejs-playpause-button').on('click', function () {
    

    现在我需要添加一些东西来运行 jplayer 播放按钮

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-28
      • 1970-01-01
      • 1970-01-01
      • 2011-01-25
      • 2013-05-29
      • 2011-03-11
      相关资源
      最近更新 更多