How can I open VLC via browser with PHP (Mac OS X)

Posted by Damiqib on Stack Overflow See other posts from Stack Overflow or by Damiqib
Published on 2010-04-01T13:04:33Z Indexed on 2010/04/01 14:03 UTC
Read the original article Hit count: 374

Filed under:
|
|

I'm trying to open VLC via browser and make it instantly play the given video file on Mac OS X.

This runs on my local server and is only meant to run locally - therefore I already run apache (MAMP) with my username and with group "staff" (defined in httpd.conf).

YES - I do know that VLC has http interface - however that is not what I need, so do not suggest that...

My current system works without any problems when I run it via Terminal:

php /var/www/Movies/index.php  

-> This leads to VLC opening and video starts playing fullscreen like intented.

Problems start when I run the same PHP-page with browser. Then the VLC-process starts, but there's no GUI for it, video file won't start playing and the VLC-process takes nearly 100% of CPU.

  • Both; terminal and browser started VLC-processes run with the same user (mine)
  • Both have "Parent process" bash
  • VLC-process begun with Terminal has empty "Process group" (only process id-number) and browser started has "httpd" + (id-number)
  • VLC-process started via browser makes 1000-times more "Mach System Calls" than it's Terminal-started counterpart.

Could anyone give me any pointers on how to get this thing working?

index.php

# $j is a file path to the videofile and is defined before
exec('/var/www/Movies/vlc.sh "' . $j . '" > /dev/null 2>&1 & echo $!;'); 

# If I do this in the given PHP-page it tells me that apache is running 
# with my username and with the group "staff" like it should be...
exec('whoamI');

vlc.sh

#!/bin/bash 
# Activate VLC in 5 seconds to make it the front-most window 
(sleep 5; open -a VLC) & 

# Open video file 
/Applications/VLC.app/Contents/MacOS/VLC --quiet --fullscreen "$1"

© Stack Overflow or respective owner

Related posts about php

Related posts about vlc