cakePHP、jQuery对话框和flowplayer工作不正常
在我的视图文件中,我有一些声音片段,我想使用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 那么我有以下几点:cakePHP、jQuery对话框和flowplayer工作不正常,jquery,cakephp,dialog,flowplayer,Jquery,Cakephp,Dialog,Flowplayer,在我的视图文件中,我有一些声音片段,我想使用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.SW
// 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"));
?>
//在/app/view/layouts中的default.ctp中:
//音频播放器信息:
$(文档).ready(函数(){
$(“.player”)。单击(函数(){
$(“”)加载($(this.attr(“href”).dialog();
返回false;
});
});
//我调用模型视图的视图文件中的示例:
//在控制器内:
/*
*用于该站点IVR音频文件的音频播放器:
*
*/
公共功能音频播放器($type,$audio,$mime){
$this->layout=false;
//$this->autoRender=false;
//确定文件的类型,以便获得位置:
如果($type==“ivr”){
$location=”“;
}否则{
$location=”“;
}
$file=$audio.“.”$mime;
$this->set(压缩(“文件”、“类型”);
}
//最后,在控制器调用的视图中(这是URL错误的地方)
$(文档).ready(函数(){
flowplayer(“播放器”,“flowplayer-3.2.11.swf”);
});
正如@ohgod所建议的,为什么路径不正确,它必须是文件的绝对路径swf文件是相对于服务器的。因此,如果您将它放在目录的根目录中,这将起作用。如果它在foldes中,则需要显式声明它们。如果可能的话,最好使用/path/to/my/flowlpayer/flowplayer-3.2.11.swf
,这将确保无论它们在哪一页上,或有多深,都会调用swf文件。@ohgod为什么要向其他人澄清,path/to/my/flowplayer
必须在webroot文件夹树上,因为如果没有,Cake将在path@Pollirrata是的,谢谢,这很重要,我把它忘了。