【问题标题】:jPlayer doesnt work within a Joomla TemplatejPlayer 在 Joomla 模板中不起作用
【发布时间】:2013-06-07 14:37:12
【问题描述】:

我用 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 中运行

【问题讨论】:

    标签: jquery jplayer joomla3.1


    【解决方案1】:

    我找到了解决方案,但我不知道为什么会这样: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 将无法正常工作。 现在看起来它首先需要较新的版本,然后是较旧的版本。

    谁能告诉我为什么这会如此令人困惑,或者它们之间有如此大的变化?

    【讨论】:

    • 我将版本 1.10.1 放在 jquery.jplayer.min.js 之前和之后,它也可以工作,所以它与版本无关。这是脚本的顺序...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 2011-04-11
    • 2011-08-13
    • 1970-01-01
    相关资源
    最近更新 更多