note 51098 deleted from function.exec by cmb
| From: | cmb@php.net | Date: | Sun, 24 Nov 2019 08:40:59 +0000 |
| Subject: | note 51098 deleted from function.exec by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213196@lists.php.net to get a copy of this message | ||
Note Submitter: bitminer at example dot com
----
I am posting this as I see quite a few people looking to create a web based interface to their MP3
player (XMMS or really what ever you want to call from the command line) on Linux. Alas, I am not
the only one, and I did not think of it first ( suppose I have to result to other get rich quick
schemes). And even if there were a direct downloadable utility (as there is XMMS-Control) you, like
me, probably want the bowl of porage that is just right. Which means you want to make your own
because current versions of X, Y, or Z just don't do what you want.
Most of the hard work is at the linux command shell (ugh! - I heard that! Drop and give me 20
command line scripts!)
login as root
ensure /dev/dsp has the proper access privileges
chmod a+rw /dev/dsp
add apache to the local list of users for the xserver.
xhost +local:apache@
You should see the following if apache is not added to the xserver.
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
** CRITICAL **: Unable to open display
And I am sure that error is as clear to you as it was to me!
NOTE !!! only change the following for testing purposes so that you can su to apache from root and
test xmms !!!!
Temporarily change the line
apache:x:48:48:Apache:/var/www:/sbin/nologin
To
apache:x:48:48:Apache:/var/www:/bin/bash
so that you can test out apache access to the Xserver and XMMS.
su apache
xmms
!!! Play a file - Don't just read this actually play a file!!! The reason is that if it fails
xmms will likely give an error you can track down like a greyhound chases that little bunny at the
dog track! (speaking of get rich quick schemes)
And for the grand finale!
If you can call xmms from the command line you can likely do the following (unless you are running
php in safe mode). Ensure that the wav, mp3, or whatever you decide to test it with is accessible
to apache. I put the file into /var/www/html/icould.wav and chmod a+rw icould.wav
<?php
echo ' Executing XMMS ';
// note you could use system too!
//echo system( '/usr/bin/xmms --play icould.wav', $retval );
exec ('/usr/bin/xmms --play icould.wav');
?>
At your browser ensure you hit shift+refresh(button) so your browser doesn't give you a cahed
the web page.
Brian J. Davis