php1 Posted August 20, 2008 Share Posted August 20, 2008 Dear all, Is there any way to play a wav file which is stored outside webroot directory. my webroot directory is : /var/www/html my wav file is stored in : /var/spool/wav/play.wav I have used passthru function but the file is not playing. my code is <?php passthru("/var/spool/wav/play.wav", $err); echo $err; ?> but $err is 0. No error I think. But file is not playing. Isthere any way to play a wav file which is stored outside the webroot directory Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/ Share on other sites More sharing options...
s1yman Posted August 20, 2008 Share Posted August 20, 2008 to start off, the $err variable is undefined in that script. try creating your link are a variable like; <?php $filename = "/var/spool/wav/play.wav"; passthru($filename.$err); echo $err; ?> passthru() is disabled on my servers for some reason so I can't test that for you, but hope it helps. Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/#findComment-620929 Share on other sites More sharing options...
php1 Posted August 20, 2008 Author Share Posted August 20, 2008 I tried as you said: <?php $filename = "/var/spool/wav/play.wav" passthru($filename,$err) echo $err; ?> But I am getting the output 0 . I actually want to play the audio file. Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/#findComment-620941 Share on other sites More sharing options...
s1yman Posted August 20, 2008 Share Posted August 20, 2008 ok, whats wrong with using the old embed tags? <embed src="yourmusic.wav" width=0 height=0 autostart=true repeat=true loop=true> </embed> Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/#findComment-620945 Share on other sites More sharing options...
php1 Posted August 20, 2008 Author Share Posted August 20, 2008 the problem is that since my wav file is tored outside webroot directory I can't use embed or ahref Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/#findComment-620950 Share on other sites More sharing options...
captbaritone Posted August 20, 2008 Share Posted August 20, 2008 Are you trying to have php output the wav file or actually PLAY the wav file? Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/#findComment-620971 Share on other sites More sharing options...
s1yman Posted August 20, 2008 Share Posted August 20, 2008 I actually want to play the audio file. The embed tags should work like this; <embed src="/dir/yourmusic.wav" width=0 height=0 autostart=true repeat=true loop=true> </embed> Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/#findComment-620978 Share on other sites More sharing options...
php1 Posted August 20, 2008 Author Share Posted August 20, 2008 I want to play the wav file. when i use embed tag like below the problem is that the page is not loading completly. <html> <body> <embed src="play.wav" width=0 height=0 autostart=true repeat=true loop=true> </embed> </body> </html> when i give like below ie when giving absolute path, a blank page is coming <html> <body> <embed src="/var/www/html/CallMonitor/play.wav" width=0 height=0 autostart=true repeat=true loop=true> </embed> </body> </html> is there any api using which we can play the audio file Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/#findComment-620991 Share on other sites More sharing options...
captbaritone Posted August 20, 2008 Share Posted August 20, 2008 PHP runs on the server. It cannot play audio on the clients machine. Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/#findComment-620995 Share on other sites More sharing options...
s1yman Posted August 20, 2008 Share Posted August 20, 2008 The page will be blank because there is no content. But the music should still be playing. Link me to your page mate Link to comment https://forums.phpfreaks.com/topic/120490-how-to-play-wav-file-which-is-stored-outside-webroot-directory/#findComment-621014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.