0

In my view files, I have soundbites which i want to play through a jQuery Dialog using flowplayer. Everything works except the player does not show. I have narrowed the problem down to where I have to provide the url to where the player's SWF file is located. I for the life of me cannot determine what location the player is looking for.

To sum it up, my files are:

flowplayer script - /app/webroot/js/flowplayer/flowplayer-3.2.10.min.js

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

Then I have the following:

 // 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"));
 ?>
mauzilla
  • 3,574
  • 10
  • 50
  • 86
  • the swf file is relative to the server. So if you have it located at the root of your directory, this would work. if it's within foldes, you should need to explicitly declare them. it would be best,if possible, to use `/path/to/my/flowlpayer/flowplayer-3.2.11.swf`, this will ensure that no matter what page they're on, or how deep they are, the swf file will be called. – Ohgodwhy Jun 22 '12 at 14:14
  • @Ohgodwhy just to clarify to everybody else, the `path/to/my/flowplayer` must be on the webroot folder tree, because if not Cake will look for a corresponding Controler/Action on the path – pollirrata Jun 22 '12 at 14:17
  • @Pollirrata yes -- thank you, that's very important and I left that out. – Ohgodwhy Jun 22 '12 at 14:19

1 Answers1

0

As suggested by @Ohgodwhy i had the path incorrect, it has to be the absolute path to the file

mauzilla
  • 3,574
  • 10
  • 50
  • 86