tags:

views:

401

answers:

1

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"
A: 

Thank you for your reply. I didn't get VLC working with this, but I proved that I can do stuff with my browser.

exec('osascript -e \'say "Hello"\'');

I got that AppleScript working via browser which was a huge victory. :D Now the problem is that apparently VLC can't be ran as root and complains: "VLC is not supposed to be run as root. Sorry. If you need to use real-time priorities and/or privileged TCP ports you can use /Applications/VLC.app/Contents/MacOS/VLC-wrapper (make sure it is Set-UID root and cannot be run by non-trusted users first). ". :(

So - the quest continues... Help is still needed to overcome this limitation...

This is where I want to make the magic happen:

$PID = exec('ps aux | grep "loginwindow" | grep -v grep | awk \'{ print $2 }\''); 
exec('sudo launchctl bsexec ' . $PID . ' /Applications/VLC.app/Contents/MacOS/VLC --quiet --fullscreen "' . $j . '" > /dev/null 2>&1 & echo $!;'); 
Damiqib