i'm trying to make an web site where the user can listen to different wav files.
I made a php
script to get all .wav
files that i want and i keep their path on an array.
Then im doing this to play the audio:
echo "<a href='teste.wav'>Play sample 1 </a>";
echo "<a href='" .$audios[$id][1] ."'>Play sample 2 </a>";
?>
<script src="http://mediaplayer.yahoo.com/js></script>
On the first case i got the audio on same folder as the script and it works fine. On the second case i have it in a completely different directory and it never finds the file.
I know that the sample 2 will ref to something directly under the current directory where the script is being executed, but i tried to make the $audios[$id][1]
like http://home/.../file.wav
and still doesn't work.
Any idea how to fix this?
/home/jorge/VOCE/Recordings/-1458206716/Tiago@Aug_31_2012_Tiago_ID_1204811836_prebaseline.wav
Do not use absolute paths. These are invalid outside your local file system. You have to use relative paths so browser can build request pointing to reachable file, so it should be more like this:
VOCE/Recordings/-1458206716/Tiago@Aug_31_2012_Tiago_ID_1204811836_prebaseline.wav
(assuming your project publicly visible folders is parent to VOCE
)
but i tried to make the $audios[$id][1] like
http://home/.../file.wav
and still doesnt work.
That would work ONLY if your browser is running physically on the same machine your server is running and filesystem is accessible to you.
EDIT
How to do this right - some assumptions (if real system differs, just make adjustments) Your filesystem structure is as follow
document-root/
scripts/
test.php
recordings/
audio.wav
index.html
document-root
is location on your disk which your httpd serves all files from. It is irrelevant what it really is. If I do http://yourdomain/index.html
then it shall show content of index.html
. Your scripts are in scripts/
folder and your audio files are in recordings
. Then relative path from test.php
to audio.wav
is ../recordings/audio.wav
. If you really need to use absolute path (not recommended) then it shall be http://yourdomain/recordings/audio.wav
. Choose what's simpliest for you.