【问题标题】:cakePHP, jQuery dialog and flowplayer not working to wellcakePHP、jQuery 对话框和 flowplayer 无法正常工作
【发布时间】:2012-06-25 20:25:22
【问题描述】:

在我的视图文件中,我有想要通过使用 flowplayer 的 jQuery 对话框播放的声音片段。一切正常,除了播放器不显示。我已将问题缩小到我必须提供播放器 SWF 文件所在位置的 url。我一辈子都无法确定玩家正在寻找的位置。

总结一下,我的文件是:

flowplayer 脚本 - /app/webroot/js/flowplayer/flowplayer-3.2.10.min.js

flowplayer SWF- /app/webroot/js/flowplayer/flowplayer-3.2.11.swf

然后我有以下内容:

 // Within the default.ctp in /app/view/layouts:

 <script type="text/javascript">
// Audio player information:
$(document).ready(function() {

   $(".player").click(function() {
      $("<div></div>").load($(this).attr("href")).dialog(); 
      return false;
   });
});
</script>

// Example in a view file where I am calling the model view:

 <?php
 echo $this->Html->link($this->Html->image("icons/control_play_blue.png", array("alt" => "Play audio file")),array("controller" => "surveys", "action" => "audioplayer","questions",$question['Question']['ivr_recording_file'], $question['Question']['mime']),array('escape' => false, "class" => "player"));
 ?>

 // Within the controller:

 /*
     * Audio player for IVR audio files for the site:
     * 
     */
    public function audioplayer($type,$audio,$mime) {

        $this->layout = false;
        //$this->autoRender = false;

        // Determine what type of file it is so that we can get the location:
       if($type == "ivr") {
           $location = "";
       } else {
           $location = "";
       }
       $file = $audio.".".$mime;

       $this->set(compact("file","type"));
    }

 // Lastly, within the view of the controller call (this is where the URL is wrong)

  <script type="text/javascript">
$(document).ready(function() {
   flowplayer("player", "flowplayer-3.2.11.swf"); 
});
 </script>
 <?php 
 echo $this->Html->Link("","/files/uploads/".$type."/".$file,array("id" => "player"));
 ?>

【问题讨论】:

  • swf 文件是相对于服务器的。因此,如果您将它放在目录的根目录中,这将起作用。如果它在文件夹内,则需要显式声明它们。如果可能,最好使用/path/to/my/flowlpayer/flowplayer-3.2.11.swf,这将确保无论他们在哪个页面上,或者他们有多深,都会调用 swf 文件。
  • @Ohgodwhy 只是为了向其他人澄清一下,path/to/my/flowplayer 必须在 webroot 文件夹树上,因为如果不是,Cake 会在路径上查找相应的控制器/操作
  • @Pollirrata 是的——谢谢,这很重要,我忽略了。

标签: jquery cakephp dialog flowplayer


【解决方案1】:

正如@Ohgod为什么我的路径不正确,它必须是文件的绝对路径

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-18
    • 2014-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多