Sagar Jadhav
Sagar Jadhav

Reputation: 74

Opening windows application (media player) using php

I have written a .php script. When there is some event, it writes to a file. It's working perfectly! Now I want to open Windows Media Player or any other player using this php script as I also want to play a sound when the event occurs. I tried embedding the sound file as follow: echo "< embed src =\"$file\" hidden=\"true\" autostart=\"true\">"; But it only writes to the file n do not play the audio, when the event occurs. I came across 'exec' command which didnt work. (I am not sure about how it works. An example would be a great help!) Does anyone know how to start a windows application using php script?

EDIT REMOVED

Thanks, Sagar.

Upvotes: 0

Views: 3077

Answers (4)

user2768584
user2768584

Reputation: 7

You can play a wave file in your server side folder in a php file by adding this <?php exec('c:\windows\system32\cmd.exe /c START C:\website\beep.wav'); ?>

and this would play the beep.wav usually through whatever sound appy is installed on your machine, like windows media player.

Upvotes: 1

Aravind
Aravind

Reputation: 1120

SagarJ,

You can embed the audio file in html and will be executed by the browser/browser plugin application already installed in the system.

So, you need not to worry about that.

Upvotes: 0

Timur
Timur

Reputation: 6718

Comment about running Windows GUI programs using PHP: http://www.php.net/manual/en/book.exec.php#87943

But, I think you only need to embed player on your page using some HTML tag as Aravind described.

Upvotes: 0

Aravind
Aravind

Reputation: 1120

You cannot start console based application through Apache+PHP application. The reason is, as Apache webserver is running as a system service in a separate logon session, it cannot start UI based applications which requires a login console session.

Anyway, you can embed the audio inside the html page. Refer the http://www.w3schools.com/html/html_sounds.asp page to get more details.

Upvotes: 0

Related Questions