Author Topic: Play Media from command line  (Read 7662 times)

lon22

  • Veteran
  • ***
  • Posts: 85
    • View Profile
Play Media from command line
« on: March 25, 2008, 12:02:12 am »
I'm trying to mimic a command sequence that begins when I play a media file with my remote. My goal is to start a movie from the command line and be able to interface with it as if I started the movie in the orbiter. I ran TailDCERouter.sh to see the sequence of DCE commands once I play a file with my remote. I then took those commands and tried to mimic them the best I could.

When I run the script below, I get the movie to play, but it is hidden behind the screen saver. If I hit the back button on my remote, I can see the movie, but if I navigate anywhere from there I lose the video. I can still hear the movie playing in the background. Can someone point me in the right direction to fix my problem.

Device ID:      Description:
147               MCE Remote
20                 orbiter
22                 xine player
23                 xine plugin
10                 media plugin
28                 screen saver
19                 core/hybrid

thanks

lon22

Code: [Select]
/usr/pluto/bin/MessageSend localhost 147 20 1 37
/usr/pluto/bin/MessageSend localhost 20 10 1 43 2 "0" 13 "85803" 29 "5" 44 "0" 45 "1" 116 "0" 117 "0"
/usr/pluto/bin/MessageSend localhost 10 -1001 2 19 27 "1"
/usr/pluto/bin/MessageSend localhost 23 22 1 37 29 "5" 41 "1001" 42 "" 59 "/home/public/data/other/Windows Share: E [100]/test.avi"
/usr/pluto/bin/MessageSend localhost 22 28 1 193 97 "0"
/usr/pluto/bin/MessageSend localhost 23 22 1 920 10 "85803" 41 "1001"
/usr/pluto/bin/MessageSend localhost 10 19 1 192 97 "0" 98 ""
/usr/pluto/bin/MessageSend localhost 10 20 1 192 97 "0" 98 ""
/usr/pluto/bin/MessageSend localhost 10 22 1 192 97 "0" 98 ""
/usr/pluto/bin/MessageSend localhost 10 20 1 242 3 "70,4964,47,140,224,230" 5 "test.avi" 9 "" 29 "5" 41 "1001" 48 "0" 50 "pluto-xine-playback-window.pluto-xine-playback-window" 103 "22,22,15,,1,1,0" 120 "0"
/usr/pluto/bin/MessageSend localhost 20 28 1 193 97 "0"
/usr/pluto/bin/MessageSend localhost 10 20 1 741 10 "" 159 "140" 251 "0" 252 "1" 253 "0"
/usr/pluto/bin/MessageSend localhost 20 10 1 74 2 "" 3 "" 8 "1" 25 "" 39 "" 45 "1" 63 "" 159 "140"
/usr/pluto/bin/MessageSend localhost 20 147 1 687 48 "102"
/usr/pluto/bin/MessageSend localhost 10 20 1 242 3 "70,4964,47,140,224,230" 5 "test.avi" 9 "" 29 "5" 41 "1001" 48 "0" 50 "pluto-xine-playback-window.pluto-xine-playback-window" 103 "22,22,15,,1,1,0" 120 "0"
/usr/pluto/bin/MessageSend localhost 22 -1001 2 58 4 "/home/public/data/other/Windows Share: E [100]/test.avi" 9 "1001" 16 "" 27 "" 47 "pcm" 48 "25:19"
/usr/pluto/bin/MessageSend localhost 20 28 1 193 97 "0"
« Last Edit: March 25, 2008, 12:07:35 am by lon22 »

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Re: Play Media from command line
« Reply #1 on: March 25, 2008, 12:19:17 am »
Hi,

You shouldn't need to replicate all those commands, in fact you should be able to start it with just a Play_Media command (sent to the Media Director device)
Using the parameters from the second last command, see if you can get the media to start from web admin and sending a command to the Media Director device, then just replicate that.

Most of the command trail that you are seeing in the log are results of other commands and also the cascading through the device tree.

If I think of it tonight I will try something similar.

Regards
Darren


lon22

  • Veteran
  • ***
  • Posts: 85
    • View Profile
Re: Play Media from command line
« Reply #2 on: March 25, 2008, 04:44:42 am »
Darren,

I sent a play media command to the xine_player via the admin website. The media plays, but the window is very small (not full screen) and I can't control the media playback with my remote. Also the photo screen saver still plays. This is the message I got from the admin webpage dialog:

Message Sent succesfully.
/usr/pluto/bin/MessageSend localhost 0 22 1 37 29 "5" 41 "1001" 42 "0" 59 "/home/public/data/other/Windows Share: E [100]/test.avi"
Response was:


lon22
« Last Edit: March 25, 2008, 04:49:09 am by lon22 »

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Play Media from command line
« Reply #3 on: March 25, 2008, 05:10:29 am »
the command in question is MH_Play_Media, and should be done from the Media Plugin, with the EntertainmentArea(s) you wish to play to. you are taking the long way around.

-Thom

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Re: Play Media from command line
« Reply #4 on: March 25, 2008, 06:09:06 am »
Thom, when you say "from the Media_Plugin" should that be "to" the Media_Plugin? Or should/could it just be given one of the 'special' devices (like -1000) which would eventually be handled by Media_Plugin.

Won't the Media_Plugin just respond to that command by "Getting" the first device in the Ent Area that is capable of handling the media type and calling Play_Media to that. I assume that would be the Media Director but I have never really traced through how this works. I guess it could return the XXX_Player device (probably Xine_Player)

I realise that what you have suggested will probably satisfy the original request, I am just trying to get a bit more understanding  for myself as it is my understanding that you have looked into this a fair bit. I am interested in how the logic works following the MH_Play_Media command that you suggested.

regards
Darren



tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Play Media from command line
« Reply #5 on: March 25, 2008, 06:36:18 am »
just send the command to device 10 (the media plugin).

-Thom

kir

  • Guru
  • ****
  • Posts: 183
    • View Profile
Re: Play Media from command line
« Reply #6 on: March 25, 2008, 12:44:48 pm »
Just a short info: when sending command MH_Play_Media to Media Plugin, you don't need to worry about things like "what is the ID of actual device that plays media in that area, etc.". In addition, assuming there can be >1 media handler for the media (now there are two already: for bluray files - MPlayer_Player, for the rest - Xine_Player), doing this manually is a a headache. Plus you have to bother about sending "Set Now Playing" messages to Orbiters.

So tschak999 is right - simply send the MH_Play_Media command to the Media_Plugin, specifying three things: URL of file you want to play, it's media type and EntArea - the system will do the rest by itself. By the way, if you are playing the file from the pluto_media table 'File' (i.e. the one that was scanned by UpdateMedia), you don't even need to pass the media type: send the URL in form "!F<PK_File>" where PK_File is the value of PK_File in File table, and EntArea to play - that's all.

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Play Media from command line
« Reply #7 on: March 25, 2008, 01:39:33 pm »
Hi,

sorry for popping into this thread,but is related...

I've started to more work with scenarios and event handlers (I'm using LMCE in new home with around 130 automation devices, 3 MDs ,etc... - a lot of fun  ??? ).

Have started Tips&Tricks with scenarios page on Wiki and would kindly ask if you can help me on the first one (it seems that matters who sends message to media plugin or am I missing something ) ? I have sniffed Playlist play command from Orbiter, but replicating same thing from scenario doesn't work...

http://wiki.linuxmce.org/index.php/Tips%26Tricks_for_various_scenarios%3F

Thanks in advance,

regards,

Bulek.
Thanks in advance,

regards,

Bulek.

lon22

  • Veteran
  • ***
  • Posts: 85
    • View Profile
Re: Play Media from command line
« Reply #8 on: March 25, 2008, 01:55:08 pm »
Using the media_plugin worked like a charm, so I guess using a plugin instead of the actual device is usually the way to go.

thanks all

lon22

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Play Media from command line
« Reply #9 on: March 25, 2008, 02:29:56 pm »
well, i must explain:

typically, plugins are designed to provide system global state, they run on the core. While the Xine_Player, and MPlayer_Player are devices at the end of the tree, much the same as a light switch, it's not the same.... why?

There's both a Xine Player and an MPlayer_Player (and many others) for each media director (or squeezebox) in the system.

When you select a media file, from the File List, an MH Play Media command is emitted from the orbiter that you are using, and is sent to the Media Plugin, This does a variety of different things:

It creates a media stream (basically state and capability encapsulation for the playing media) mapping first to the player templates that can play them, then back up the chain to the plugins that can handle those players (this is done in the Register function of each plugin, which basically pushes itself onto a vector of the registered media plugins for a given player template). Once this is done, the job of the plugin is to find the devices that it needs to go to, and send them commands to play the appropriate media.

The Media Plugin also encapsulates a LOT of additional functionality as well, such as making sure the appropriate audio and video pipes are active (is the TV on? is the reciever on?, does it need to be?), making sure that floorplan objects and datagrids are updated, making sure that the appropriate remotes are bound. (Binding a remote refers to keeping it in a list, and making sure that any changes to both the display that needs to be displayed, and the elements on that display are kept in sync.. such as changing the orbiter displays when a DVD menu is present, or updating the cover art object), triggering Set Now Playing to make sure that any scenarios that are attached are triggered appropriately (the showtime scenario etc) as well as making sure the metadata to show on the orbiters is correct and so on..so on.

Remember, that this system is multi-homed, and that if you trigger player objects, things will suddenly break when you start moving things around or expand into other areas of the home.

-Thom

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Re: Play Media from command line
« Reply #10 on: March 25, 2008, 11:24:36 pm »
When you select a media file, from the File List, an MH Play Media command is emitted from the orbiter that you are using, and is sent to the Media Plugin, This does a variety of different things:

It creates a media stream (basically state and capability encapsulation for the playing media) mapping first to the player templates that can play them, then back up the chain to the plugins that can handle those players (this is done in the Register function of each plugin, which basically pushes itself onto a vector of the registered media plugins for a given player template). Once this is done, the job of the plugin is to find the devices that it needs to go to, and send them commands to play the appropriate media.


Thom, The media stream that is created, is this a generic object and how does it relate to the media streams that each plugin/player (eg; xine) has?
Is there a distinction between audio and video streams? Is the audio for a video handled as a seperate stream?

Also, is it media_plugin and only media_plugin responsibility to turn URL's into media streams or does it pass this off to other plugins?


tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Play Media from command line
« Reply #11 on: March 26, 2008, 12:21:07 am »
When you select a media file, from the File List, an MH Play Media command is emitted from the orbiter that you are using, and is sent to the Media Plugin, This does a variety of different things:

It creates a media stream (basically state and capability encapsulation for the playing media) mapping first to the player templates that can play them, then back up the chain to the plugins that can handle those players (this is done in the Register function of each plugin, which basically pushes itself onto a vector of the registered media plugins for a given player template). Once this is done, the job of the plugin is to find the devices that it needs to go to, and send them commands to play the appropriate media.


Thom, The media stream that is created, is this a generic object and how does it relate to the media streams that each plugin/player (eg; xine) has?
Is there a distinction between audio and video streams? Is the audio for a video handled as a seperate stream?

Also, is it media_plugin and only media_plugin responsibility to turn URL's into media streams or does it pass this off to other plugins?



This is an object of type MediaStream (see MediaStream.cpp). There is a StreamID for each piece of media started in the system, doesn't matter what it is, the number starts at 1000 for streams started by the media plugin, and increments.

It's the Media Plugin subclass's responsibility to do this. Look at Xine_Plugin.cpp for details.. also look at XineMediaStream.cpp.

-Thom