-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
writing bytes to omxplayer's OutputStream from java #116
Comments
Have you looked into using the dbus interface (from java) to control omxplayer? |
Wow! quick reply...many many thanks! No, I haven't looked at dbus...Would you happen to have any links handy? |
Well, you want to implement code similar to: There appears to be a dbus-java package which may be helpful. |
I am at a complete loss here...After many hours I managed to install dbus-java and also found this: http://code.google.com/p/rocksources/wiki/OMXPlayerDbus which I managed to install on the Pi. However, trying to do 'CreateInterface' as described here : http://wiki.apertium.org/wiki/Compiling_a_Java_D-Bus_program , fails. All I changed is the interface name: CreateInterface raspberry.pi.OMXPlayer / > pi/OMXDBUSPLAYER.java
CreateInterface raspberry.pi.OMXPlayerList / > pi/OMXDBUSPLAYLIST.java
Do I need to somehow start the omxplayer-dbus service? |
Does omxplayer run for you and have working keyboard? You'll need something like the current omxplayer wrapper which starts a dbus daemon: |
From the command-line it runs and responds to keystrokes just fine. From my Java application it starts but doesn't respond to keystrokes. I am currently trying to adapt my code so that it uses the dbus service but inorder to do that I need to generate some Interfaces, namely the raspberry.pi.OMXPlayer and raspberry.pi.OMXPlayerList, before I can even compile...
I think have the latest build of omxplayer [9b52cee] because it updated a week or so ago. When exactly does it start the deamon? When omxplayer starts or when the pi boots up? I cannot express how grateful I am for taking the time to reply to me even if the issue is not resolved...many thanks :) |
Ok I think I've made some progress...I checked my omxplayer wrapper script and it does indeed start the dbus-deamon. I am not sure it closes it (ps xaf shows many instances) after playback but at least it starts it. So, it follows that I should be able to do the following while omxplayer is running, in order to generate the interfaces I need.
However this still fails with the same message: "the name raspberry.pi.OMXPlayer was not provided by any .service files". The same for raspberry.pi.OMXPlayerList. The other alternative is to somehow find the 'introspection.xml' for omxplayer and generate the interfaces from there. The funny thing is that if I knew the right name I could generate the xml automatically, while the process is running! But I know neither the right name, nor I can find the introspection.xml... if you can provide either of these (dbus service name or introspection.xml), it should be straight forward to generate the interfaces and I can finally start to write the controlling code. thanks in advance |
I'd guess this is the dbus name: |
It is not unfortunately...Moreover, DBusViewer shows a bunch of processes but none related with omxplayer, even though omxplayer is streaming radio in the background! Screenshot can be found here: https://dl.dropboxusercontent.com/u/45723414/2013-12-18-184028_1280x720_scrot.png would it perhaps be easy for you to install dbus-java on your pi and then type DBusViewer in a terminal, while omxplayer is playing something? Can you find the omx dbus process under 'SESSION'? I can't remember when it was the last time I struggled so much to generate an interface.... |
You must listen the good 'DBUS_SESSION_BUS_ADDRESS' and dbus name. omxplayer + Java on RaspBerry ;( 2 Terminal = 2 sessions |
Hi fcarlier, I'm not sure what you mean...could you elaborate a bit further? do you happen to know what dbus-process to listen to? |
I installed mdbus2 on my pi but doing guys, what on earth is happening? should I just give up? |
I can confirm that omxplayer ignores control characters from STDIN, when it's coming from a pipe. See #131. |
Hi @jimpil I installed mdbus2 on my raspberry pi. Executing it shows
Of course you only see the second line when omxplayer is running ;) Also notice that mdbus2 without any argument looks default to the SESSION bus. Initial implementations of omxplayer ran on the SYSTEM bus. Nowadays omxplayer is running on the session bus. So I assume that you are up-to-date. You looked at the 'rocksources' OMXPlayerDbus implementation. Although that code (interface) seems fine, it isn't the one omxplayer uses. Omxplayer D-Bus interface implements the "MPRIS D-Bus Interface Specification" (MEDIAPLAYER2) interface. So you should use the OMXPLAYER_DBUS_xxx values which are defined in omxplayer's OMXControl.h. BUT when I say omxplayer I refer to POPCORNMIX omxplayer. Are you using this one? Because you talk about raspberry.pi.OMXPlayerList. At this moment omxplayer doesn't have playlist support, and that interface name is definitly wrong/unknown to omxplayer. 'rocksources' omxplayer on the otherhand has this interface, so are you using that omxplayer code? Maybe that would explain why you get confused by above comments ;) I glanced through the 'rocksources'; it uses the SYSTEM bus. |
Hi @jehutting, First of all thank you for taking the time to investigate. What you say makes sense and that is actually what I tried to do. You are right that initially I got confused by the 'rocksources' dbus interface, but later on I realised that I need to implement a different interface, namely the org.mpris.MediaPlayer2.omxplayer. Now I have a couple of questions...you say that 'executing mdbus2 while omxplayer is running'...how exactly are you doing this? On my pi, if I open a separate terminal than the one omxplayer is using, and type 'mdbus2', I get nothing back, presumably because it is a different SESSION. But there is no way to run omxplayer and the mdbus2 command in the same terminal, is there? Ultimately, I want to generate the Java interface. In order to do that I need either the XML file containing the introspection data, or by querying the remote object over D-Bus, via 'CreateInterface'. My problem is that I cannot find the remote object...Once I generate the Java interface, I literally need nothing else in order to write a rudimentary playlist for omxplayer... Any suggestions? |
Hi @jimpil, Just like you do, I open an ssh connection to my raspberry pi, and run omxplayer within it. Then I start a second ssh connection and execute mdbus2 in it. It shows the "org.mpris.MediaPlayer2.omxplayer" in its output. I would expect that you should at least see 'org.freedesktop.DBus'. I run omxplayer.bin directly, so not using the omxplayer script. I'm not able to run that script, so I can't check if this makes the difference. Are you running direct or through the script? If through the script, maybe you can try it out if a direct run makes the difference. I'm also curious what a "ps xaf | grep -i dbus" gives as output (on the second ssh terminal).
As you can see I have only ONE dbus-daemon (and don't get multiple ones). The one and only is started up as a result of omxplayer running. It isn't killed after omxplayer ends playing, but that is another issue ?-) If you don't get a dbus-daemon, it tells me that your omxplayer is not using/running a D-Bus connection. In one of your above comment, you checked that you were able to control omxplayer by keyboard. Is that still the case? Does it pause when you hit e.g. the 'p'-key? I now assume you are running the POPCORNMIX omxplayer? I'm not a Java expert and don't know about the 'CreateInterface' stuff. It is also unknown on my RPI. I could install the java package and give it a try to see what kind of output I get. But probably that still won't give you the ability to use it yourself. |
On 18/01/14 13:34, Jozef Hutting wrote:
If you don't mind can you try the following? Install java-dbus on your CreateInterface --session --create-files org.mpris.MediaPlayer2.omxplayer Does it create the interface I need, in the correct hierarchy? Jim |
On 18/01/14 13:34, Jozef Hutting wrote:
When I do exactly what you describe I get: Can't hook to DBus session bus: Command line `dbus-launch apparently it needs an X window running!!! It seems to me that the only way to run mdbus2 is from within X where How did you run mdbus2 from ssh??? Jim |
from within X, mdbus2 gives me:
I assume that everything is fine...the problem is how to run mdbus2 and omxplayer in the same session. |
Regarding your questions on a previous message, I am pretty sure I am using POPCORNMIX omxplayer as I installed it through the official raspbian repos. I am also guessing it is up to date as I update regularly...in fact I remember it was recently updated (start of December if I am not mistaken). Also the keys work just fine from ssh. I am launching omxplayer, via the |
Oops...I see I forgot a little small but very important detail. Sorry for that! You MUST use the -X (capital X) option of ssh. This does X11 forwarding and sets some environment settings correct for the terminal (/shell/session). One of them is DISPLAY. Without a correct value you get your problem. So WITHOUT the -X you get
and WITH the -X you get the mdbus2 output and something like
I don't run the GUI (X11 windows) on my RPI. Just from the plain command line (CLI) through ssh. I will start the X Windows and see if there is any difference between GUI and CLI behavior. I can install java-dbus for you. But is there anything that I need further more to see if that is working. Any specific java tool? But I am still curious what a "ps xaf | grep -i dbus" says. From plain CLI and now also from GUI if possible. |
Right ok we are getting somewhere...so you are right. using the -X switch it works. However, it only reports org.freedesktop.DBus, even though omxplayer is running! I guess this is a major problem...Now, on the terminal where I typed mdbus2, I typed "ps xaf | grep -i dbus" and this is what I got:
I am not sure what to make of this though... :( |
From what I remember you don't need anything else to try out yourself. Just |
this is the exact command: maybe you can omit the |
I am sorry I did not remember correctly! The package is called |
OK. Great! What I make of the ps output is
Remember that I'm running omxplayer.bin, so without the script that I'm unable to run. So the forked dbus-daemon is the only difference here!? Can't imagine mdbus2 has trouble with multiple dbus-daemons. Meanwhile I tried to install the java-dbus, but got Maybe you can try to run omxplayer.bin or adjust the omxplayer script NOT to fork the dbus-daemon. |
how exactly are you running omxplayer.bin? I seem unable to simply run the I don't understand why you get this error!!! are you not on raspbian? |
this is getting weirder and weirder! I followed your advice and did what Andyjagoe did...commented out all the DBUS calls from the script and rebooted. Suddenly mdbus2 shows However before we get happy and stuff check this out:
weird stuff yes? |
Hi Jim, I'm also on raspbian and what I meant using omxplayer.bin directly is that one should
Without it you are indeed unable to run omxplayer. For my 'conversion' problem, I solved that finally. For someone interested in that, seems to be that you MUST have en_US as one of your locales. I only had 'en' and 'nl' (=dutch). Silly me thinking I could live without these Americans :-)) Anyway it is great to see that WITHOUT the dbus-daemon forking in the script mdbus2 is showing omxplayer! That is really great. Seems mdbus2 has trouble with the forked daemon, or only recognizes this one as the ONLY valid one. I'm just guessing here! But what if it does do so? How is that forked dbus-daemon session'ed to omxplayer. Or is there always ONLY ONE D-Bus SESSION active? Really don't know. Have to dive more into D-Bus to figure that out. But that is more for issue #59. Being able to install the java stuff, I ran into some /usr/lib/jvm/default-java not found error. Installed oracle jdk, but that didn't solved it. Turns out default-java is just a link to your selected jdk. I choose
Bummer. But...nevertheless.. I would say.. so far so good. |
Good-morning Jozef, I do appreciate your efforts....let's summarize the situation common to us:
According to this link (http://www.mabishu.com/blog/2010/11/15/playing-with-d-bus-interface-of-spotify-for-linux/) Also, I should have said that last night but my original
but it still fails for you too!!! Also, now that you have Java, could you also try Do you get a responsive keyboard when running omxlayer.bin directly? |
After a moment of enlightenment, I sat on my ubuntu desktop-pc, fired up VLC, which also implements the I am happy to report that I finally got my Java interfaces, under the correct directory hierarchy!!! YAY!!! I guess that I can now start programming against those interfaces, but at some point I am going to have to test my code against omxplayer. |
Hi Jim, that was a great idea you had 🎱 I am still trying to understand D-Bus. From what I understand from the CreateInterface call is that it does an Introspect call/request to -in our case- omxplayer interface. From OMXControl code I don't see anything what looks like supporting this request. It should give some XML back. I think that CreateInterface makes there a nice Java code (class??) out of it. Ha ha ha...I tried to do the same as you did. But now I'm having the same problem as you had with the RPI; mdbus2 not recognizes vlc, and vlc doesn't provide any services. Unbelievable ;))))) |
If I understand correctly, any Yes, CreateInterface, querys the Introspectable remote object, generates the XML and from that it generates the java source files (only interfaces). VLC uses DBUS for more that 2 years now...I find it very weird mdbus2 doesn't show it! Actually it should show something like this:
are you on VLC 2 or greater? In any case, I now have the interface and after quite a bit of fiddling I managed to compile everything! I am confused because I thought that all I had to do was to write a wrapper class (satisfying all 3 interfaces) that delegates to the actual remote object. I am having trouble finding a nice tutorial and so now I am not sure which remote object to use as the code says nothing about anyway I can't even test it against vlc because I get exceptions that no service is provided with the name org.mpris.MediaPlayer2. Why does it have to be so hard?!!! |
Hi Jim, I have VLC 2.0.5. Maybe I have to plug-in something. But I also have guayadeque, which also supports MPRIS2. On my Linux Mint PC
You should recognize some things from your CreateInterface call. CreateInterface fails here too; no java code just bloody warnings ignoring properties ?-) So above output shows what you can do with connection (DESTINATION) 'org.mpris.MediaPlayer2.guayadeque' to OBJECT_PATH '/org/mpris/MediaPlayer2' through INTERFACE 'org.mpris.MediaPlayer2.Player' with a MEMBER (e.g. PlaybackStatus).
As you can see it tells me that the player is 'Stopped' and that's correct! The music just stopped playing. Great isn't it!? What also sould work is
but that miserably fails. Don't know why? By the way, DESTINATION is a unique connection name. It identifies the application on the D-Bus. Other application use this to connect (though D-Bus ;-) to that application. Another great music player is Clementine, also supporting the MPRIS2 interface. Running BOTH players, you get with mdbus2 :
The last 2 are for MPRIS1 interfacing. Now when playing with vlc the DESTINATION should be 'org.mpris.MediaPlayer2.vlc'. I guess... change in above dbus-send command ONLY the destination an see what happens. For omxplayer the DESTINATION is 'org.mpris.MediaPlayer2.omxplayer'. So..still, in my opinion...so far so good. |
Tried DBusViewer on the GUI. It shows in the SESSION tab
Pressing the
Found a similar message in issue #61 and #110. But we already knew that Introspection fails ;-). |
How is this working with latest omxplayer and dbus changes? |
As long as omxplayer hasn't implemented the Introspectable interface, the CreateInterface command will still fail. As dbus seems to work well (using the dbuscontrol.sh proves it) I assume that @jimpil (or others) should be able to control omxplayer with a java application despite the absent of the Introspectable interface. |
I vote for closing this one. |
@jimpil can you close this issue? |
Sure, closing it now... |
Hello everyone,
First of all I should clarify that this is probably not an issue with omxplayer...it seems that some people have managed to spawn and control an omxplayer Process from Java code but I can't find any working code anywhere! Now that oracle-java-7 is in the official repos, I've written a rudimentary playlist GUI for the pi.
I can successfully spawn the omxplayer process but there is no way to control it from my code...The Process runs until the video/song finishes and then it starts over!!! Only option is to reboot...I've literally tried everything and I am following all the best practices (buffered streams and ProcessBuilder). Here is the code snippet that should write the bytes for quitting omxplayer (q char):
However ,the above code pattern does not work for anything (volume, pausing, quitting etc). I 've even tried putting the code that starts the Process in a separate thread and still nothing.
I do realise that this is not the most appropriate place to ask for help but I am slightly desperate! I cannot think of anything else to try out...To my surprise, p.destroy() doesn't work either!!! Any help/pointers are greatly appreciated...
many thanks in advance,
Jim
The text was updated successfully, but these errors were encountered: