如何运行与PHP Web脚本输出音频扬声器在Linux上的mplayer? [英] How to run mplayer with audio speaker output from PHP web script on linux?

查看:109
本文介绍了如何运行与PHP Web脚本输出音频扬声器在Linux上的mplayer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我登录到Linux feora 15发行版使用用户名:计算器。
我的浏览器在本地系统中执行PHP脚本发挥使用PHP系统(mplayer的/tmp/stackoverflow.wav),中继(mplayer的/tmp/stackoverflow.wav)命令的音乐。如Linux命令。

随着计算器我不听到任何音频的用户。但我可以看到mplayer的/tmp/stackoverflow.wav运行其中有8分钟音频持续时间。

我的问题是:如何使用PHP系统(mplayer的/tmp/stackoverflow.wav);切换用户,并运行相同的命令,这样我可以听到我的音乐和我的PHP?

 < PHP
// 例如
switchuser(苏计算器密码);
系统(mplayer的/tmp/itworks.wav);
?>


解决方案

直接回答你的问题是使用须藤,如

 系统(sudo的-u<用户名>的mplayer /tmp/itworks.wav)

不过,我不知道这会解决您的问题。首先,你在哪里想要的声音输出?服务器或客户端/浏览器?上述技术将在服务器上工作。对于浏览器,你需要让客户端加载.wav文件作为通过插件的对象或一些这样和处理它,presumably。

您提到,你可以看到,虽然运行mplayer的过程?如果你是在服务器(或服务器和客户端是同一台物理计算机上),你听不到任何输出,那么还有别的事情。这有可能是Web服务器进程的用户没有使用音频卡的权限,但我怀疑mplayer的过程会持续这么长时间没有与终止权限被拒绝的错误。为了搞清这一点,我们就需要更多的信息我想

I am logged in to linux feora 15 distro with username: stackoverflow. My browser execute in the local system a PHP script to play a music using PHP system("mplayer /tmp/stackoverflow.wav"), passthru("mplayer /tmp/stackoverflow.wav") command. Such as linux command.

As a user stackoverflow i dont hear any audio. But i can see that mplayer /tmp/stackoverflow.wav is running which has duration of 8minutes audio.

My question is: how can i use PHP system("mplayer /tmp/stackoverflow.wav"); to switch user and run the same command, so that i can hear my music with my PHP?

<?php
// for example
switchuser("su stackoverflow password");
system("mplayer /tmp/itworks.wav");
?>

解决方案

The direct answer to your question would be to use sudo, as in

system("sudo -u <username> mplayer /tmp/itworks.wav")

But, I'm not sure this will solve your problem. Firstly, where do you want the sound outputted? The server or the client/browser? The above technique will work on the server. For the browser, you'd need to get the client to load the .wav file as an object or some such and deal with it, presumably via a plugin.

You mention that you can see a running mplayer process though? If you are at the server (or the server and client are on the same physical machine) and you can't hear any output, then there's something else going on. It's possible that the web server process user doesn't have permission to use the audio card, but then I doubt the mplayer process would continue for so long without terminating with "permission denied" error. To figure this out, we'd need more info I guess

这篇关于如何运行与PHP Web脚本输出音频扬声器在Linux上的mplayer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆