1

我正在尝试使用 jplayer 播放在自定义字段中添加的 mp3 文件。因此,当我在帖子 jplayer 中单击 mp3 文件时,会抓取 mp3 文件,但到目前为止它只显示文件名和艺术家,但我无法让它真正播放文件。

我在 single.php 上使用此代码:

<div class="mp3jplayer-track">
<a class="playprogram" href='javascript:initMp3("<?php echo $mp3_url; ?>", "<?php echo $mp3_name; ?> - <?php /*if there is an artist specified for each mp3, we get it, otherwise we get the taxonomie Artists*/ if ($mp3_artists != ''){ echo 'Artist(s): '.$mp3_artists;}  else { echo 'Artist(s): '.$artists_names; } ?>")'>Play <br><span class="mp3_name"><i class="icon-music icon-white"></i><span class="mp3_name_text"><?php echo $mp3_name ?></span></span></a>   </div>

jplayer 在我的页脚中看起来像这样:

<div id="jp_container_1" class="jp-audio">
    <div class="jp-type-single">
        <div class="jp-gui jp-interface">
            <ul class="jp-controls">
                <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
                <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
                <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
            </ul>

            <!--
            <ul class="jp-toggles">
                <li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>
                <li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>
            </ul>
            -->

            <div class="jp-progress-group">
                <div class="jp-current-time"></div>
                <div class="jp-progress">
                    <div class="jp-seek-bar">
                        <div class="jp-play-bar"></div>
                    </div>
                </div>
                <div class="jp-duration"></div>
            </div>

            <div class="jp-volume-group">
                <a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a>
                <a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a>
                <div class="jp-volume-bar">
                    <div class="jp-volume-bar-value"></div>
                </div>
                <a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a>
            </div>

            <div class="jp-time-holder">

            </div>

        </div>
        <div class="jp-title">
            <ul>
                <li></li>
            </ul>
        </div>

        <div class="jp-no-solution">
            <span>Update Required</span>
            To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
        </div>

    </div>
</div>

以及加载 mp3 的 javascript:

function initMp3(mp3file, mp3info){
jQuery.noConflict()(function($){
/* DEBUG
window.alert(mp3file);
window.alert(mp3info);
*/

$("#jp_container_1").css("display","block");

$("#jquery_jplayer_1").jPlayer( "clearMedia" );
$("#jquery_jplayer_1").jPlayer( "setMedia" , {
    mp3:mp3file
});

$("#jquery_jplayer_1").jPlayer({
    ready: function () {
        $(this).jPlayer("setMedia", {
            mp3:mp3file
        }).jPlayer("play");
    },

    swfPath: "js",
    supplied: "mp3",
    wmode: "window"
})

$(".jp-title ul li").text(mp3info);
$("#jquery_jplayer_1").jPlayer("play");

});
};

我真的搜索过,但我找不到为什么它不起作用,知道吗?

4

1 回答 1

0

好的,我解决了这个问题,我的 swf 路径被破坏了,由于某种原因,firefox 无法使用 html 播放器......

于 2013-02-24T16:39:52.087 回答