在我的视图文件中,我有想要通过使用 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"));
?>