Stellen Sie die Lautstärke mit PHP Exec und einem Mixer ein
Ich habe ein kleines PHP-Skript geschrieben, um die Lautstärke meines lokalen Rechners mit alsa zu steuern:
<?php # for simplicity and testing it really just executes the command: echo exec('amixer set Master 5%+') . " \n";
Wenn ich dieses Skript jetzt in der Befehlszeile ausführen, funktioniert es gut:
$ php volume.php Front Right: Playback 39226 [60%] [on] $ php volume.php Front Right: Playback 42503 [65%] [on] $ php volume.php Front Right: Playback 45780 [70%] [on]
Ich habe Musik gespielt und ich höre, wie sie lauter wird.
Aber wenn ich versuche, das Skript über den Browser aufzurufen http://localhost/volume.php
, funktioniert es nicht.
# http://localhost/volume.php Front Right: Playback 55709 [10%] [on] # F5 Front Right: Playback 55709 [15%] [on] # F5 Front Right: Playback 55709 [20%] [on]
Jetzt höre ich keine Änderung der Lautstärke und die Prozentsätze scheinen in keinem Zusammenhang mit dem aktuellen Zustand zu stehen. Es sagt 10% - 15% - 20%, wenn es wirklich noch bei 70% liegt.
Mein Apache läuft als mein Benutzer und exec('whoami')
gibt mir den Benutzernamen, mit dem ich angemeldet bin, auf meiner Shell, wo alles gut funktioniert.
# httpd.conf User mkt Group mkt
Ich bin auf Fedora 22.
Wahrscheinlich liegt es an der Prozessumgebung von Apache2. Irgendwelche Ideen, wie man das beheben kann?
UPDATE :
Dies ist die Ausgabe von aplay -L:
[mkt@localhost ~]$ aplay -L null Discard all samples (playback) or generate zero samples (capture) pulse PulseAudio Sound Server default Default ALSA Output (currently PulseAudio Sound Server) sysdefault:CARD=Intel HDA Intel, ALC888 Analog Default Audio Device front:CARD=Intel,DEV=0 HDA Intel, ALC888 Analog Front speakers surround21:CARD=Intel,DEV=0 HDA Intel, ALC888 Analog 2.1 Surround output to Front and Subwoofer speakers surround40:CARD=Intel,DEV=0 HDA Intel, ALC888 Analog 4.0 Surround output to Front and Rear speakers surround41:CARD=Intel,DEV=0 HDA Intel, ALC888 Analog 4.1 Surround output to Front, Rear and Subwoofer speakers surround50:CARD=Intel,DEV=0 HDA Intel, ALC888 Analog 5.0 Surround output to Front, Center and Rear speakers surround51:CARD=Intel,DEV=0 HDA Intel, ALC888 Analog 5.1 Surround output to Front, Center, Rear and Subwoofer speakers surround71:CARD=Intel,DEV=0 HDA Intel, ALC888 Analog 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers iec958:CARD=Intel,DEV=0 HDA Intel, ALC888 Digital IEC958 (S/PDIF) Digital Audio Output hdmi:CARD=NVidia,DEV=0 HDA NVidia, HDMI 0 HDMI Audio Output hdmi:CARD=NVidia,DEV=1 HDA NVidia, HDMI 1 HDMI Audio Output hdmi:CARD=NVidia,DEV=2 HDA NVidia, HDMI 2 HDMI Audio Output hdmi:CARD=NVidia,DEV=3 HDA NVidia, HDMI 3 HDMI Audio Output
In der Befehlszeile funktionieren nur Standard und Impuls:
amixer -D pulse set Master 5%+ amixer -D default set Master 5%+
Mit PHP funktionieren auch diese beiden nicht. Wie auch immer ... mein Sound kommt von meinen Monitor-Lautsprechern, die über HDMI angeschlossen sind. Die letzten 4 Geräte sind also meine Kandidaten. Aber keiner von ihnen arbeitet.
$ amixer -D hdmi:CARD=NVidia,DEV=0 set Master 5%+ $ amixer -D hdmi:CARD=NVidia,DEV=1 set Master 5%+ $ amixer -D hdmi:CARD=NVidia,DEV=2 set Master 5%+ $ amixer -D hdmi:CARD=NVidia,DEV=3 set Master 5%+
In allen vier Fällen heißt es: (bei DEV = [0-3] natürlich)
ALSA lib control.c:954:(snd_ctl_open_noupdate) Invalid CTL hdmi:CARD=NVidia,DEV=3 amixer: Mixer attach hdmi:CARD=NVidia,DEV=3 error: No such file or directory
AKTUALISIEREN
Ausgabe von aplay -l:
$ aplay -l **** Liste der Hardware-Geräte (PLAYBACK) **** Card 0: Intel [HDA Intel], Device 0: ALC888 Analog [ALC888 Analog] Sub-Devices: 1/1 Sub-Device #0: subdevice #0 Card 0: Intel [HDA Intel], Device 1: ALC888 Digital [ALC888 Digital] Sub-Devices: 1/1 Sub-Device #0: subdevice #0 Card 1: NVidia [HDA NVidia], Device 3: HDMI 0 [HDMI 0] Sub-Devices: 1/1 Sub-Device #0: subdevice #0 Card 1: NVidia [HDA NVidia], Device 7: HDMI 1 [HDMI 1] Sub-Devices: 0/1 Sub-Device #0: subdevice #0 Card 1: NVidia [HDA NVidia], Device 8: HDMI 2 [HDMI 2] Sub-Devices: 1/1 Sub-Device #0: subdevice #0 Card 1: NVidia [HDA NVidia], Device 9: HDMI 3 [HDMI 3] Sub-Devices: 1/1 Sub-Device #0: subdevice #0 $ amixer -c0 set Master 5%+ $ amixer -c1 set Master 5%+
Beides funktioniert nicht!
0 Antworten auf die Frage
Verwandte Probleme
-
4
Gutes freies Ubuntu Server-VMWare-Image benötigt
-
1
Apache Reverse Proxy
-
3
Ubuntu Server mit GNOME Desktop Envinronment - Einstellen der Apatche-Konfigurationsdateiberechtigun...
-
8
Wie kann ich allen Benutzern in Linux Schreibzugriff auf einen Ordner gewähren?
-
5
Gibt es einen * guten * HTML-Modus für Emacs?
-
6
Audio-Line-In unter Ubuntu / Linux Mint
-
4
Gibt es eine Möglichkeit, die Lautstärke unter Linux zu erhöhen / verringern, ohne ein grafisches We...
-
1
Apache2-Fehlerprotokoll
-
4
Überprüfen, welche PHP-Version ich unter Linux laufe?
-
2
Mac OS X-Bash: Deinstallieren Sie alle Apache- und PHP-Vorfälle