Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

omxplayer web remote controls for any web enabled device

Wed Aug 29, 2012 1:31 pm

Hello!
This is my first contribution to raspberry pi community. Please do not judge too hard.
The idea is to control raspi' omxplayer sitting on the sofa near your raspi-connected TV -
Using any of your web enabled device. I've been testing in on my smartphone via wifi.
It is web app + ajax + some ugly shell scripts.
Have a look at the screenshot and the video to get the idea:
Image
http://www.youtube.com/embed/8QeWDKIpAAw

You can get it here:
https://github.com/JugglerLKR/omxplayer ... ntrols-php
and configure it with setup.php

It requires group write permissions to working directory and some permissions to output video to /dev/vchiq and running shell script using sudo.

Obviously you need working omxplayer, apache2 and php 5 :lol:

I've implemented some basic error checking and suggestions what should be done to run it properly, but ofcourse it has bugs! Please avoid spaces and international characters and all that utf8 stuff if possible in the beginning. :oops: It only filters .mkv and .avi for now.

Thanks goes to authors of omxplayer, raspi creators and raspi community for some hints and tips, Neil Ang for PHP Simple file browser, Dmitry Koterov for his excellent JsHttpRequest 5 cross-browser AJAX.

p.s.: I will update this post with more details... But now it just works!

Earlofevil
Posts: 6
Joined: Sat Sep 15, 2012 4:19 pm

Re: omxplayer web remote controls for any web enabled device

Sat Sep 15, 2012 4:39 pm

Hallo,
Finde ich sehr interessant dein projekt. Werde ich bald ausprobieren.
Bin auf der suche nach einer möglichkeit mehrere pi, die an projektoren angeschlossen sind, über einen server zu steuern. Denkst du dein projekt liesse sich in diese richtung erweitern/modifizieren?

Gruss, philipp

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Sat Sep 15, 2012 6:34 pm

this one only for omxplayer remote, not to control "whole" pi. try vnc & ssh scripting if you want "total control".

Earlofevil
Posts: 6
Joined: Sat Sep 15, 2012 4:19 pm

Re: omxplayer web remote controls for any web enabled device

Sat Sep 15, 2012 7:07 pm

:lol: ... i had to laugh about myself. because i read so many posts and websites in english
to this topic I got so used to english, that i simply replied in german.
... although i could have done it in english. sorry for that.

my intent is not to control the pi totally, but to control the video playback of many pi clients.
an example-setup could look like this:

1 server (with web interface), 3 clients (with local videofiles)
Server "A" tells:
- RPI client "A" to play video file "1"
- RPI client "B" to play video file "2" (in repaet mode)
- RPI client "C" to play video file "3" then video file "4"

this could would be a very scalable solution for multi-projector-installations.

I have to test your project entirely, to give you a better feedback, but for now it's the
solution which fits most.

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Sun Sep 16, 2012 1:00 pm

it is very easy to modify php + js code. you can build interface to multiple pis on top of my ideas within a few hours. you could use python too. the most ugly part is setup with permissions and shell scripts. the rest is very easy to understand.

Earlofevil
Posts: 6
Joined: Sat Sep 15, 2012 4:19 pm

Re: omxplayer web remote controls for any web enabled device

Tue Sep 18, 2012 9:22 pm

Thanks,
It fits basic purposes. Now i have to go deeper into the code.
Do you think there is an option to display the duration and current positon?

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Wed Sep 19, 2012 9:24 am

you have to check if omxplayer provide such info at startup via stdout or stderr. if it does, it is possible to capture its output using the same fifo mechanism and parse it with regexp. then you can update timeline in browser once a second using javascript. the trckiest part is to calculate server(pi) and client(browser) times difference, but it is possible too.

Earlofevil
Posts: 6
Joined: Sat Sep 15, 2012 4:19 pm

Re: omxplayer web remote controls for any web enabled device

Wed Sep 19, 2012 5:34 pm

Thank you for the hint!

bobbydriver
Posts: 68
Joined: Thu Oct 18, 2012 9:06 am

Re: omxplayer web remote controls for any web enabled device

Fri Nov 09, 2012 10:12 pm

Wow - got this working and it does all I need it too...seriously good work. Might not be pretty but it does the job!

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Fri Nov 09, 2012 10:52 pm

it was just a proof of concept...

bobbydriver
Posts: 68
Joined: Thu Oct 18, 2012 9:06 am

Re: omxplayer web remote controls for any web enabled device

Sat Nov 10, 2012 3:45 pm

Well it works! SO you proved the concept!

If you ever do a fuller version, then let me know...

lonespeaker
Posts: 1
Joined: Sat Nov 10, 2012 8:07 pm

Re: omxplayer web remote controls for any web enabled device

Sat Nov 10, 2012 8:15 pm

Thanks for providing the code as I intend to write something similar myself. I've been using xmbc on my PI but getting really fed up with how unstable it is, so I decided to look into creating a web based media player. What I am thinking of doing is creating a web based app that gets fan art, show info etc just like xbmc but without the overheads/unstableness as well as some sort of realtime monitoring of the system.

Your code has saved me some time in working out an efficient way to communicate with omxplayer so thanks again.

agiovacchini
Posts: 2
Joined: Sun Dec 02, 2012 11:55 am

Re: omxplayer web remote controls for any web enabled device

Sun Dec 02, 2012 12:01 pm

Thank you so much for this code, it's so useful! Now I can use my phone as a remote

ncurses
Posts: 3
Joined: Sat Dec 29, 2012 12:38 pm

Re: omxplayer web remote controls for any web enabled device

Sat Dec 29, 2012 12:47 pm

Hi,

I have a problem with setup.php I encounter this error :

Code: Select all

/dev/vchiq is not writable for httpd user
you have to run shell command:
sudo usermod -a -G video www-data
'this will allow http server user which runs omxplayer access /dev/vchiq to display video
www-data is correctly in video group (in /etc/group) but is_writable() return false.

If I change user using su - www-data and run omxplayer with :

Code: Select all

omxplayer -o hdmi movie/tbbt.avi 
it's work.

But not apparently usiging php. What is the problem ?

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Sat Dec 29, 2012 1:11 pm

ncurses, if you are familiar with linux try to find out which user runs apache and php. the problem lies in permissions which I cannot address from script. Try to run everything from root-like account and see if it works. Then try to find out which permissions are missing. script is very simple so you can debug it yourself easily.

ncurses
Posts: 3
Joined: Sat Dec 29, 2012 12:38 pm

Re: omxplayer web remote controls for any web enabled device

Sat Dec 29, 2012 2:11 pm

Thanks for fast responce.

I have try to change some persmition and same problem.

Your script run as root, pi and www-data user work. But when i try to run it with system() function in php :
* not permission to write on vchiq
Run system(' omxplayer -o hdmi tbbt.avi') make error.

Same with exec() and shell_exec();

The problem come maybe from version of apache2.
what version are you using ?

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Sat Dec 29, 2012 11:30 pm

ncurses - have you enabled group write permissions to working directory?

ncurses
Posts: 3
Joined: Sat Dec 29, 2012 12:38 pm

Re: omxplayer web remote controls for any web enabled device

Sun Dec 30, 2012 8:15 pm

Yes, i am. But I start my rasberry this morning and it's work. Problem are gone :D

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Sun Dec 30, 2012 8:21 pm

ncurses wrote:Yes, i am. But I start my rasberry this morning and it's work. Problem are gone :D
Glad it works! :lol:

blackkelpie
Posts: 2
Joined: Fri Jan 25, 2013 11:33 pm

Re: omxplayer web remote controls for any web enabled device

Sat Jan 26, 2013 12:16 am

Hi there,

For some reason I cannot get the sound to work when I'm using the remote controls. Any ideas? When I start OMXplayer through SSH sound works ok but I can't hear a thing when using the web controls.

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Sat Jan 26, 2013 7:01 am

check starting script. sound output defaults to hdmi.
https://raw.github.com/JugglerLKR/omxpl ... /setup.php

$omxsh = "#!/bin/sh\nsudo sh -c \"./cls.sh\"\nomxplayer -p -o hdmi \"$1\" <".FIFO." >/dev/null 2>&1 &\nsleep 1\necho -n . >".FIFO."\n";

change -hdmi the way you prefer.

blackkelpie
Posts: 2
Joined: Fri Jan 25, 2013 11:33 pm

Re: omxplayer web remote controls for any web enabled device

Wed Jan 30, 2013 8:23 am

eh...to what?

DVI? That had no result at all. Nothing showed up.

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Wed Jan 30, 2013 11:04 am

please read omxplayer manual.

MontyPithon
Posts: 5
Joined: Sat Mar 23, 2013 5:02 pm

Re: omxplayer web remote controls for any web enabled device

Sat Mar 23, 2013 5:15 pm

Hi,

I am currently working on a similar project (more as an exercise really) and I am running into trouble when starting omx via my web interface. I am controlling it via FIFO and this works quite nicely. When I start omx from a terminal or ssh with or without X I can send controls from the interface through the FIFO. However, when I try to start omx using something like

Code: Select all

shell_exec('omxplayer OPTIONS FILE < FIFO') 
or

Code: Select all

shell_exec('cat FIFO | omxplayer OPTIONS FILE')
in my php code all it does is wish me a nice day and quit. I am new to the Pi and it really is a blast messing around with this thing but this is starting to bug me a bit.
Any Ideas?

Regards,

Eike

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer web remote controls for any web enabled device

Sat Mar 23, 2013 7:30 pm

MontyPithon wrote: Any Ideas?
I faced the same problems, so I went FIFO way. No ideas what was wrong with command-line.

Return to “Media centres”