jPlayer在Joomla模板中不起作用

时间:2013-06-07 14:37:13

标签: jquery jplayer joomla3.1

我用jPlayer创建了一个Joomla模板。

以下是代码(我尽可能简单,播放器中的代码来自jplayer.org):

<?php
    defined( '_JEXEC' ) or die( 'Restricted access' );
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Chin Up!</title>

    <link type="text/css" rel="stylesheet" href="http://jplayer.org/latest/skin/pink.flag/jplayer.pink.flag.css" >

    <script type="text/javascript" src="http://jplayer.org/latest/js/jquery.jplayer.min.js" ></script>
    <script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/jquery-1.10.1.min.js"></script>
    <script type="text/javascript">
    //<![CDATA[
    $(document).ready(function() {

        $("#jquery_jplayer_1").jPlayer({
            ready: function(event) {
                $(this).jPlayer("setMedia", {
                    mp3: "http://jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3",
                    oga: "http://jplayer.org/audio/ogg/TSP-01-Cro_magnon_man.ogg"
                });
            },
            swfPath: "http://jplayer.org/latest/js",
            supplied: "mp3, oga"
        });
    });
    //]]>
  </script>
</head>

<body>

    <div id="jquery_jplayer_1" class="jp-jplayer"></div>

    <div id="jp_container_1" class="jp-audio">
        <div class="jp-type-single">
            <div class="jp-gui jp-interface">
                <ul class="jp-controls">

                    <!-- comment out any of the following <li>s to remove these buttons -->

                    <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-mute" tabindex="1" title="mute">mute</a></li>
                    <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
                </ul>

                <!-- you can comment out any of the following <div>s too -->

                <div class="jp-progress">
                    <div class="jp-seek-bar">
                        <div class="jp-play-bar"></div>
                    </div>
                </div>
                <div class="jp-volume-bar">
                    <div class="jp-volume-bar-value"></div>
                </div>                 
            </div>
        </div>
    </div>

</body>
</html>

现在的问题是它没有播放这首歌......什么都没发生。 唯一有效的是玩家可见。 我在没有Joomla的情况下使用相同的玩家离线创建了一个网站,并且它工作得很好......

Joomla 3.1.1版 和Joomla在XAMPP中运行

1 个答案:

答案 0 :(得分:0)

我找到了一个解决方案,我不知道为什么这样做有效:D 我在网站上找到了一个jPlayer的网站,我将所有Javascript代码复制到我的项目中... 它正在工作......所以我删除了一些脚本标签。

现在我在标题中的脚本看起来像这样:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/jplayer/jquery.jplayer.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript">
        //<![CDATA[
        jQuery.noConflict();
        $(document).ready(function(){
            $("#jquery_jplayer_1").jPlayer({
                ready: function () { // When the jPlayer is ready to use
                    $(this).jPlayer("setMedia", { mp3: "http://localhost/Joomla-3.1.1/images/audio/The_Hellacopters_-_In_The_Sign_Of_The_Octopus.mp3" }); // Set the file which should be played
                },
                play: function() { // When the Play-Button is clicked
                    $(this).jPlayer("pauseOthers"); // To avoid multiple jPlayers playing together
                },
                swfPath: "jplayer/Jplayer.swf", // Set the File for flash (if html doesnt work this file is the source for the player)
                supplied: "mp3", // Tell the jPlayer which file type (codec) should be used
                cssSelectorAncestor: "#jp_container_1", // The buttons (links) in the div with this id will take effect on this jPlayer
            });

           $("#jquery_jplayer_2").jPlayer({
                ready: function () { // When the jPlayer is ready to use
                    $(this).jPlayer("setMedia", { mp3: "http://localhost/Joomla-3.1.1/images/audio/3_Doors_Down_-_Believer.mp3" }); // Set the file which should be played
                },
                play: function() { // When the Play-Button is clicked
                    $(this).jPlayer("pauseOthers"); // To avoid multiple jPlayers playing together
                },
                swfPath: "jplayer/Jplayer.swf", // Set the File for flash (if html doesnt work this file is the source for the player)
                supplied: "mp3", // Tell the jPlayer which file type (codec) should be used
                cssSelectorAncestor: "#jp_container_2", // The buttons (links) in the div with this id will take effect on this jPlayer
            });
        });
        //]]>
    </script>

有趣的是,如果我切换脚本,jPlayer无法正常工作。 现在它看起来首先需要更新版本,然后是旧版本。

任何人都可以告诉我为什么会这么混乱,或者他们之间有这么大的变化吗?