Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Hardware & Software > Software players

Reply
 
Thread Tools Search this Thread Display Modes
Old 31st January 2008, 18:30   #1  |  Link
dimzon
BeHappy/MeGUI developer
 
dimzon's Avatar
 
Join Date: Oct 2003
Location: Moscow, Russia
Posts: 1,727
MPC HC - Feature Requests: advanced API for complete control from another program

Dear developers!
As i said before i'm looking for API to control MPC from my HTPC application, written in C#. What I really need:

1) obtain notifications (playback started/completed)
2) now playing file info including properties, lenght and position
3) obtain list of avaluable audio tracks and current audio track
4) obtain list of avaluable subtitles and current subtitle
5) obtain chapter list
6) manipulate current playlist
7) turn subtitle by name/index (obtained from 3)
8) turn audio by name/index (obtained from 2)
9) get and set current audio delay
10) set current position

You can implement this via WM_COPYDATA or via NamedPipes or via HTTP.

dimzon is offline   Reply With Quote
Old 31st January 2008, 19:59   #2  |  Link
Casimir666
Registered User
 
Join Date: Jan 2007
Posts: 455
Check you mailbox
__________________
Tired of tearing?
Try this Media Player Classic mod : http://mpc-hc.sourceforge.net
Casimir666 is offline   Reply With Quote
Old 1st February 2008, 15:13   #3  |  Link
dimzon
BeHappy/MeGUI developer
 
dimzon's Avatar
 
Join Date: Oct 2003
Location: Moscow, Russia
Posts: 1,727
Quote:
Originally Posted by Casimir666 View Post
Check you mailbox
Hi!
Unfortunally I havn't Internet Connection at my home and I can't use MSM at my office. Oh, and my Inbox is 97% full. So why not just discuss this API into thread?

talking about implementation I think the best way will be to use STDIN/STDOUT and special command-line parameter, for example /SLAVE. In this case MPC will listen commands from STDIN and reply to STDOUT. For example I can propose such protocol

EXEC MPC.EXE /SLAVE
STDOUT: MPC, version XXX, bla-bla-bla
STDIN:CREATE PLAYLIST n // where n means playlist size
STDIN:fileName1.avi
STDIN:fileName2.avi
...
STDIN:fileNamen.avi
STDIN:PLAY x // where [B]x[X] means playlist position
STDOUT:PLAYBACK STARTED
STDOUT:fileName
STDIN:LIST AUDIO STREAMS
STDOUT:n m // where n means count, m means current stream
STDOUT:STREAM NAME 1
STDOUT:STREAM NAME 2
...
STDOUT:STREAM NAME n
STDIN: SET AUDIO STREAM [b]x[b]

etc...

What does You think?
dimzon is offline   Reply With Quote
Old 1st February 2008, 19:06   #4  |  Link
Casimir666
Registered User
 
Join Date: Jan 2007
Posts: 455
I think the WM_COPYDATA will be easier. As argument you give me you app main windows handle :

Start : EXEC MPC.EXE /SLAVE 0x1000D1

Dialog message could then be a string starting with a code and the parameters :

Ex :
// After launch MPC -> Your App : code 1 follow by MPC window handle
1|0x120120

// Add to playlist Your App -> MPC : code 2 follow by filenames
2|filename1|filename2

...

Is it ok for you?
__________________
Tired of tearing?
Try this Media Player Classic mod : http://mpc-hc.sourceforge.net
Casimir666 is offline   Reply With Quote
Old 4th February 2008, 14:35   #5  |  Link
dimzon
BeHappy/MeGUI developer
 
dimzon's Avatar
 
Join Date: Oct 2003
Location: Moscow, Russia
Posts: 1,727
I think yes, WM_COPYDATA is sutable too
by the way: to avoid any mistakes let's use UTF8 encoding for filenames etc.
dimzon is offline   Reply With Quote
Old 10th February 2008, 12:29   #6  |  Link
Casimir666
Registered User
 
Join Date: Jan 2007
Posts: 455
It's not entirely finished, but i have a first release for mpc API downloadable from here : http://www.zshare.net/download/7381233e7c777c/

API test program is available on SF here :
http://mpc-hc.svn.sourceforge.net/vi...ps/MPCTestAPI/


Currently available functions are :
1) obtain notifications (playback started/completed)
2) now playing file info including properties, lenght and position
6) manipulate current playlist (add, clear, start playing)
9) set current audio delay (no get yet)
10) set current position
+ Standard commands : open, play, pause, stop, close


For the "Get" functions how do you want to proceed? You send a cmd "Ask for XXX" and i return a notification with the value?
It's not possible to return data via WM_COPYDATA messages isn't it?
__________________
Tired of tearing?
Try this Media Player Classic mod : http://mpc-hc.sourceforge.net
Casimir666 is offline   Reply With Quote
Old 11th February 2008, 13:22   #7  |  Link
dimzon
BeHappy/MeGUI developer
 
dimzon's Avatar
 
Join Date: Oct 2003
Location: Moscow, Russia
Posts: 1,727
Quote:
Originally Posted by Casimir666 View Post
It's not entirely finished, but i have a first release for mpc API downloadable from here : http://www.zshare.net/download/7381233e7c777c/

API test program is available on SF here :
http://mpc-hc.svn.sourceforge.net/vi...ps/MPCTestAPI/


Currently available functions are :
1) obtain notifications (playback started/completed)
2) now playing file info including properties, lenght and position
6) manipulate current playlist (add, clear, start playing)
9) set current audio delay (no get yet)
10) set current position
+ Standard commands : open, play, pause, stop, close
Fine, i will check this asap



Quote:
Originally Posted by Casimir666 View Post
For the "Get" functions how do you want to proceed? You send a cmd "Ask for XXX" and i return a notification with the value?
It's not possible to return data via WM_COPYDATA messages isn't it?
Yes, it isn't possible. There are 2 ways to return value
1) if value is small (fits to 32bit signed integer) it's possible return it as LRESULT
2) send WM_COPYDATA as answer

Last edited by dimzon; 11th February 2008 at 13:31.
dimzon is offline   Reply With Quote
Old 11th February 2008, 14:07   #8  |  Link
dimzon
BeHappy/MeGUI developer
 
dimzon's Avatar
 
Join Date: Oct 2003
Location: Moscow, Russia
Posts: 1,727
Hey, Casimir666 I found yet another way for "Get" functions
Actually we can use WM_GETTEXT to obtain data from MPC. So you just need to create special invisible window or control witch contains everything in XML form (and update it every time something changed). For example:
Code:
<mpc-info>
  <current-file>C:\myvideo.avi<current-file>
  <duration>01:21:57</duration>
  <position>01:09:32</position>
  <audio-delay-in-ms>0</audio-delay-in-ms>
  <subtitle-delay-in-ms>0</subtitle-delay-in-ms>
  <audio-track index="1" active="yes">AC3 Russian</audio-track>
  <audio-track index="2">AC3 English</audio-track>
  <show-subtitles>no</show-subtitles>
</mpc-info>
What do you think?
dimzon is offline   Reply With Quote
Old 11th February 2008, 16:11   #9  |  Link
dimzon
BeHappy/MeGUI developer
 
dimzon's Avatar
 
Join Date: Oct 2003
Location: Moscow, Russia
Posts: 1,727
what information I need asap:
Code:
		private string[] audioTracks;
		private string[] subtitles;
		private int currentAudioTrack;
		private int currentSubtitle;
		private int audioDelay;
		private int subtitleDelay;
		private string[] playlist;
		private int currentFile;
		private string[] chapters;
		private int currentChapter;
		
		private TimeSpan duration;
		private TimeSpan position;
Some ideas about playlist. Actually, even if you open one file will be created playlist. So I doesn't need current-file but i need complete playlist (array of full file pathes) and index of current file.
dimzon is offline   Reply With Quote
Old 24th February 2008, 23:37   #10  |  Link
MatMaul
Registered User
 
Join Date: Apr 2004
Posts: 402
what about define a string model and send it by a WM_COPYDATA message ?

for example for a CMD_GETPLAYLIST :
current_file|nb_of_files|file1|file2|...

CMD_GETAUDIOTRACKS :
current_audio|nb_of_audio|audio1|audio2|...

CMD_GETSUBTRACKS :
sub_are_active|current_sub|nb_of_sub|sub1|sub2|...

I will try to implement something like that during the week.
MatMaul is offline   Reply With Quote
Old 25th February 2008, 08:24   #11  |  Link
Casimir666
Registered User
 
Join Date: Jan 2007
Posts: 455
Dimzon I'm terribly confused i realize i haven't respond to your questions, and i didn't works on you API for the last 2 weeks. MatMaul is now a member of mpc-hc and he can give you a hand for this :-)

I agree with him it's better to stay on wm_copy messages to communicate between both application. About you question on OSD : the actual implementation in mpc is far from perfect, and it have several problems :
- didn't works with all renderer
- on windowed vmr, OSD is set before resizing
- it's quite ugly

Maybe you can keep you OSD solution for the moment, and we will see later if we can do better osd than can be pilot remotly...
__________________
Tired of tearing?
Try this Media Player Classic mod : http://mpc-hc.sourceforge.net
Casimir666 is offline   Reply With Quote
Old 26th February 2008, 12:24   #12  |  Link
dimzon
BeHappy/MeGUI developer
 
dimzon's Avatar
 
Join Date: Oct 2003
Location: Moscow, Russia
Posts: 1,727
Hi!
Actually obtaining information via WM_GETTEXT is much more easy to implement in both sides (MPC must update this invisible window and client don't need to catch to many different messages.

And some additional ideas (just ideas, what do you think)
1) How about to make MPC out-of-process COM server?
2) How about to split MPC into 2 parts. First part - mplayerc.dll will contain everything playback-related. Second part mplayerc.exe will be frontend.
dimzon is offline   Reply With Quote
Old 26th February 2008, 16:09   #13  |  Link
MatMaul
Registered User
 
Join Date: Apr 2004
Posts: 402
sorry I don't know very well how to do with WM_GETTEXT and I began to do it yesterday with WM_COPYDATA.
here is my work :
http://www.etud.insa-toulouse.fr/~mv...pc_api_test.7z

I will think about how to do with WM_GETTEXT.

EDIT : in this case we also need a XML API. I don't want to use msxml because it will add a dependancy (it is not staticaly linkable).

Last edited by MatMaul; 26th February 2008 at 16:13.
MatMaul is offline   Reply With Quote
Old 26th February 2008, 17:41   #14  |  Link
dimzon
BeHappy/MeGUI developer
 
dimzon's Avatar
 
Join Date: Oct 2003
Location: Moscow, Russia
Posts: 1,727
Quote:
Originally Posted by MatMaul View Post
sorry I don't know very well how to do with WM_GETTEXT and I began to do it yesterday with I will think about how to do with WM_GETTEXT.
Actually you doesn't need to do anything complex. Just create invisible window and update it's text everytime...

Quote:
Originally Posted by MatMaul View Post
in this case we also need a XML API. I don't want to use msxml because it will add a dependancy (it is not staticaly linkable).
You doesn't need any XML API in this case - everything you need is simple string concatenation and special symbol replacement
dimzon is offline   Reply With Quote
Old 26th February 2008, 21:50   #15  |  Link
MatMaul
Registered User
 
Join Date: Apr 2004
Posts: 402
I added some new features, you can choose the subtitle and audio tracks now,get the playlist, the list of audio tracks and subtitle tracks.
it is available for testing on the same link.
MatMaul is offline   Reply With Quote
Old 26th February 2008, 22:32   #16  |  Link
Casimir666
Registered User
 
Join Date: Jan 2007
Posts: 455
Quote:
Originally Posted by dimzon View Post
1) How about to make MPC out-of-process COM server?
It's a little more complicated (need one interface for command and one for callback), and need to be register executable on machine to works. Maybe we will stay on the wm_copymessage solution for the moment


Quote:
Originally Posted by dimzon View Post
2) How about to split MPC into 2 parts. First part - mplayerc.dll will contain everything playback-related. Second part mplayerc.exe will be frontend.
Could be interesting, but i have no idea how complicated it will be to transform mpc in dll...
__________________
Tired of tearing?
Try this Media Player Classic mod : http://mpc-hc.sourceforge.net
Casimir666 is offline   Reply With Quote
Old 2nd March 2008, 00:30   #17  |  Link
jmnk
Registered User
 
Join Date: Feb 2006
Posts: 149
Quote:
Originally Posted by MatMaul View Post
sorry I don't know very well how to do with WM_GETTEXT and I began to do it yesterday with WM_COPYDATA.
here is my work :
http://www.etud.insa-toulouse.fr/~mv...pc_api_test.7z

I will think about how to do with WM_GETTEXT.

EDIT : in this case we also need a XML API. I don't want to use msxml because it will add a dependancy (it is not staticaly linkable).
how do I use inclued sample app? when I try to run it I get 'cannot be executed' error. Do I miss some microsoft libraries? Any help woul dbe greatly appreciated.
jmnk is offline   Reply With Quote
Old 7th March 2008, 15:33   #18  |  Link
linx05
Registered User
 
Join Date: Mar 2005
Location: Region 4
Posts: 518
@Casimir666
When will we see this API added to the latest releases of MPC HC? I am very interested in seeing MPC have an API.
linx05 is offline   Reply With Quote
Old 7th March 2008, 22:50   #19  |  Link
MatMaul
Registered User
 
Join Date: Apr 2004
Posts: 402
commited in the svn repository.
here is a build :
http://www.etud.insa-toulouse.fr/~mv...layerc_r443.7z

Some features are still missing.
MatMaul is offline   Reply With Quote
Old 7th March 2008, 23:12   #20  |  Link
Casimir666
Registered User
 
Join Date: Jan 2007
Posts: 455
Quote:
Originally Posted by jmnk View Post
how do I use inclued sample app? when I try to run it I get 'cannot be executed' error. Do I miss some microsoft libraries? Any help woul dbe greatly appreciated.
API sample application is also available in SF :
http://mpc-hc.svn.sourceforge.net/vi...ps/MPCTestAPI/
__________________
Tired of tearing?
Try this Media Player Classic mod : http://mpc-hc.sourceforge.net
Casimir666 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:50.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.