Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP: media views for mp3 files streamed with flash player
    primarykey
    data
    text
    <p>I have a page with a audio flash player that streams several mp3 files. This player uses an XML file that has the path of all those files, which are in a <strong>audio</strong> folder in the webroot directory.</p> <p>What I don't like is that it's pretty easy for a user to get to the XML file (which is also in the webroot directory) and see the paths of the mp3 files, and then download them instead of just using the flash player.</p> <p>I've seen that CakePHP has something called <strong>Media Views</strong>, where you can set a folder outside the webroot and place your files there, so users can't freely access them. The explanation in Cake's website (http://book.cakephp.org/view/1094/Media-Views) is focused on files to download, but I would like to know if I can use the Media Views to stream my mp3 files with the audio player without making them downloadable by the users. OR if there's any other alternative without Media Views that would work as well :)</p> <p>Thanks so much in advance!</p> <p><strong>CLARIFICATION</strong></p> <p>This is the code that I'm using that I would like to change:</p> <p><strong>- In my controller:</strong></p> <pre><code>function index() {} </code></pre> <p><strong>- In my view (index.ctp):</strong></p> <pre><code>&lt;embed type="application/x-shockwave-flash" flashvars="audioUrl=/audios/01 Track 01.mp3" src="audio-player.swf"&gt;&lt;/embed&gt; </code></pre> <p>=>How can I change that using Media Views so that my mp3 file is in a folder app/audios instead of app/webroot/audios?</p> <p><strong>THIS IS WHAT I'VE TRIED:</strong></p> <p><strong>- In my controller (streams_controller.php):</strong></p> <pre><code>function index() {} function getFile() { $this-&gt;view = 'Media'; $params = array( 'id' =&gt; '01 Track 01.mp3', 'name' =&gt; '01 Track 01', 'download' =&gt; false, 'extension' =&gt; 'mp3', 'path' =&gt; APP . 'audios' . DS, 'cache' =&gt; true ); $this-&gt;set($params); } </code></pre> <p><strong>- In my view (index.ctp):</strong></p> <pre><code>&lt;embed type="application/x-shockwave-flash" flashvars="audioUrl=/streams/getFile" src="audio-player.swf"&gt;&lt;/embed&gt; </code></pre> <p>STILL NO LUCK! What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload