Find the answer to your Linux question:
Results 1 to 3 of 3
I'm trying to do a simple task but it has proven very difficult for me so I appreciate all of the help! I'm trying to get a URL that will ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2013
    Posts
    2

    Play audio file from browser command


    I'm trying to do a simple task but it has proven very difficult for me so I appreciate all of the help! I'm trying to get a URL that will command a raspberry pi to play an audio file. In other words, any time someone hits the URL it will play a sound out of a pair of speakers hooked up to the raspberry pi. Here's what I have and know so far...

    I have simple perl script that I have been able to play the file from the command prompt: aplay sound.wav

    I know that I need a cgi-script to do this but I can't seem to get the perl script to play the sound. I have been able to get some simple perl scripts to run in the browser but getting the sound file to play has alluded me! Thank you for any help!

  2. #2
    Just Joined!
    Join Date
    May 2013
    Posts
    2
    Let me give a little more information on where I am...

    I currently have this script:
    #!/usr/bin/perl
    system("mplayer /var/www/police_s.wav")

    and when I run that from a browser (localhost/cgi-bin/script.pl) I get the results of the script running but the sound does not play. I'm running this on a raspberry pi with a pair of speakers hooked up.

    I'm running out of options and this task is killing me! Any help is appreciated...I am new to this and running out of steam.

  3. #3
    Linux Enthusiast
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    518
    Have you tried running the command:

    mplayer /var/www/police_s.wav

    just like normal to see if it works like normal? Perhaps the location is incorrect. mplayer is very flexible, but fails like any other when fed wrong info. Why would there be wav files sitting in /var/www/?

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •