INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: COM Interface  (Read 5456 times)

tonyno

  • Recent member
  • *
  • Posts: 9
COM Interface
« on: January 22, 2008, 10:09:46 pm »

Cool looking app. I'm checking things out and have been looking through the automation docs. I've been able to control playback, but would like to get info. Is there support for this via COM?
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42372
  • Shoes gone again!
Re: COM Interface
« Reply #1 on: January 22, 2008, 11:22:59 pm »

Yes, you can do a lot with in-proc and out-of-proc automation.  More information here:
http://wiki.jrmediacenter.com/index.php/DevZone
Logged
Matt Ashland, JRiver Media Center

tonyno

  • Recent member
  • *
  • Posts: 9
Re: COM Interface
« Reply #2 on: January 23, 2008, 06:57:38 am »

Thanks, but obviously I was clear as mud. ;D

There is one big page there that shows the enum's for a lot of messages, but none that I can find for messages that return info from MC.

I'm looking at switching from Winamp. This is for whole-house audio, controlled by my HA app (PowerHome) via Windows Messages.
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: COM Interface
« Reply #3 on: January 23, 2008, 07:40:56 am »

What sort of info are you looking for?
It's quite easy to get stuff like information about tracks out,
or the current playing track.

Code samples are a bit fragmented, but they're growing.

tonyno

  • Recent member
  • *
  • Posts: 9
Re: COM Interface
« Reply #4 on: January 23, 2008, 10:09:38 pm »

I'd like to start with artist/album/track name, current track length (time), current track position, current track path, and next track artist/track. I also have some code to pull  a variable number of previous/next tracks in the current playlist (current track ±n tracks). I think this is all I currently use with Winamp.
Logged

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: COM Interface
« Reply #5 on: January 23, 2008, 10:15:21 pm »

Take a look at:

http://wiki.jrmediacenter.com/index.php/MJCurPlaylistAutomation

That will get you started...

j

tonyno

  • Recent member
  • *
  • Posts: 9
Re: COM Interface
« Reply #6 on: January 24, 2008, 06:45:25 am »

That would be great if it showed the enum's for them (message number, wparam, lparam).  :D

I downloaded the SDK just to see if I could find them, but saw nothing.

I did piece together that, for volume control to n%, the numbers were 33768, 10020, n.
Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: COM Interface
« Reply #7 on: January 24, 2008, 07:41:28 am »

That would be great if it showed the enum's for them (message number, wparam, lparam).  :D

I downloaded the SDK just to see if I could find them, but saw nothing.

I did piece together that, for volume control to n%, the numbers were 33768, 10020, n.
i use the 33768 also, the 10020 and the n can be found in this table http://wiki.jrmediacenter.com/index.php/Media_Center_Core_Commands
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: COM Interface
« Reply #8 on: January 24, 2008, 08:49:34 am »

Eh?
There's confusing cross referencing here..
The enum stuff is for controlling MC via the command line interface.
Using the COM Interface is different as a sample script from my C#
Script plugin shows:
______________________________________________-
using System;
using System.Windows.Forms;
//css_reference MediaCenter.dll;

class Script : MarshalByRefObject
{
    public void Init(MediaCenter.MCAutomation mediaCenterInterface)
    {       
        //Show a Sample Message Box Proving we are running!
        MessageBox.Show("I am a Running Script!");

        //Set the Volume Of Media Center!
        MediaCenter.IMJMixerAutomation MCMixer;
        MCMixer = mediaCenterInterface.GetMJMixer();
        MCMixer.Volume = 20;   
     
    }
}
____________________________________
No need for Enums.

The full automation documentation is found here
http://wiki.jrmediacenter.com/index.php/Media_Center_Automation#Automation_Objects

John was pointing you towards the stuff specifically relating to the "Playing Now" playlist.

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: COM Interface
« Reply #9 on: January 24, 2008, 10:31:48 am »

tonyno - perhaps you could be clearer on what you are trying to do.

j

tonyno

  • Recent member
  • *
  • Posts: 9
Re: COM Interface
« Reply #10 on: January 24, 2008, 12:52:28 pm »

OK, maybe I'm confusing terminology then.  ;D

I'm looking to use/control MC without a plug-in (switch from using Winamp without a plug-in). I can send/receive Windows Messages, so I figured that'd be a good way to start.
Logged

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: COM Interface
« Reply #11 on: January 24, 2008, 01:06:17 pm »

Now I understand. Powerhome runs on the same PC as Media Center, right? And sends messages via Windows Messaging to the Media Center application.

What other ways does Powerhome have of communicating? Is "Windows Messages" the only one?

j

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: COM Interface
« Reply #12 on: January 24, 2008, 01:23:36 pm »

We've got tons of commands you can send with Windows Messaging. See the wiki here:

http://wiki.jrmediacenter.com/index.php/Media_Center_Core_Commands
I'm in the process of updating the SDK, it'll include the latest and greatest list of these.

j

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: COM Interface
« Reply #13 on: January 24, 2008, 01:54:28 pm »

We don't have any commands that return info though: how does Winamp return the information? Strings are not normally safe to return for these.

j

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: COM Interface
« Reply #14 on: January 24, 2008, 03:21:04 pm »

Okay, the SDK now has the latest and greatest list of commands -- j

tonyno

  • Recent member
  • *
  • Posts: 9
Re: COM Interface
« Reply #15 on: January 24, 2008, 08:05:31 pm »

Wow. Four replies!  ;D

Quote
What other ways does Powerhome have of communicating? Is "Windows Messages" the only one?
PH can also use TCP/UDP sockets plus Do you have something in mind?

Quote
how does Winamp return the information?
Example:
Current playlist length is returned with message 1024, 0, 124.
Logged

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: COM Interface
« Reply #16 on: January 24, 2008, 08:44:09 pm »

Wow. Four replies!  ;D

Kind of a work in progress for me today....

Quote
PH can also use TCP/UDP sockets plus Do you have something in mind?

I noticed that, was wondering how it worked. Is there some sort of standard they follow?

Quote
Current playlist length is returned with message 1024, 0, 124.

But how do they return the current playing track name?

j

tonyno

  • Recent member
  • *
  • Posts: 9
Re: COM Interface
« Reply #17 on: January 24, 2008, 09:29:00 pm »

Sockets are pretty generic:

ph_sendsocketdata ( url, port, data )
url  String. The IP or hostname of the remote device to communicate with. 
port  Long. The Port of the remote device to communicate with. 
data  String. The data to send via a socket to the remote device

Returning strings... It's been a while since I've done this by hand! I believe it uses WM_COPYDATA. I'll need to see if I can find the details.

Looks like a hack was implemented...
http://forums.winamp.com/showthread.php?s=7e72fca65fa000092eac71c03905b057&threadid=196494

PH also does xPL. Maybe a plug-in exists for MC...
Logged

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: COM Interface
« Reply #18 on: January 25, 2008, 10:45:58 am »

For sockets: I'm most interested in the data string. Is it an open protocol, or something proprietary?

Looks like Winamp has the same problem returning strings.

xPL looks interesting, and looks like it could be done with a plug-in. I don't know if one exists, but you could write it...

j

tonyno

  • Recent member
  • *
  • Posts: 9
Re: COM Interface
« Reply #19 on: January 25, 2008, 12:59:33 pm »

Socket Data: All open; whatever you want.
Logged

mhakman

  • World Citizen
  • ***
  • Posts: 206
Re: COM Interface
« Reply #20 on: February 06, 2008, 06:02:10 pm »

If you cannot get PH to make COM calls then you could write a script (VB or any other supporting COM including Java) that talks with PH using whatever PH supports and with MC using COM. It maybe is a long way but doable.

Logged

tonyno

  • Recent member
  • *
  • Posts: 9
Re: COM Interface
« Reply #21 on: February 07, 2008, 01:14:44 pm »

Ooh. Does that mean that there are some VBS/Java examples? I'll have to look...
Logged

mhakman

  • World Citizen
  • ***
  • Posts: 206
Re: COM Interface
« Reply #22 on: February 07, 2008, 06:13:26 pm »

Here is a simple example in VB. You need to add a reference to MediaCenter.tlb to your VB project. In Java you do it in a corresponding way but you need a tool that will generate COM interfaces for MC based on MediaCenter.tlb. There is a number of such tools both commertial and free (open source). I’m using Jawin from http://sourceforge.net/projects/jawinproject/

Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim mcAutomation As MediaCenter.IMJAutomation
    Dim mcFilesAutomation As MediaCenter.IMJFilesAutomation
    Dim mcPlaybackAutomation As MediaCenter.IMJPlaybackAutomation
    Dim mcCurPlaylistAutomation As MediaCenter.IMJCurPlaylistAutomation
    Dim start As Boolean

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' First try to get automation interface to an already running Media Center
        On Error Resume Next
        mcAutomation = GetObject(, "MediaJukebox Application")

        If Err.Number = 429 Then
            ' If MC is not runing then start it and get interface
            mcAutomation = CreateObject("MediaJukebox Application")
        End If
        ' Get interfaces to playback and to playing now list
        mcPlaybackAutomation = mcAutomation.GetPlayback()
        mcCurPlaylistAutomation = mcAutomation.GetCurPlaylist()
        ' Get all files in MC library
        mcFilesAutomation = mcAutomation.Search("")
        ' Add all these files to playing now
        Dim file As MediaCenter.IMJFileAutomation
        Dim i As Integer
        Dim key As Integer
        For i = 1 To mcFilesAutomation.GetNumberFiles()
            file = mcFilesAutomation.GetFile(i)
            key = file.GetKey()
            mcCurPlaylistAutomation.AddFileByKey(key, i)
        Next
        start = True
    End Sub

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' If not playing right now
        If mcPlaybackAutomation.State <> MediaCenter.MJPlaybackStates.PLAYSTATE_PLAYING Then
            ' Play
            If start Then
                ' Start playing playing now list
                mcFilesAutomation.Play(0)
                start = False
            Else
                ' Toggle pause state = play whatever was playing
                mcPlaybackAutomation.Pause()
            End If
            Button1.Text = "Pause"
        Else
            ' Toggle pause state = pause
            mcPlaybackAutomation.Pause()
            Button1.Text = "Play"
        End If
    End Sub
End Class
Logged

surfikus

  • Recent member
  • *
  • Posts: 11
Re: COM Interface
« Reply #23 on: August 08, 2008, 04:20:10 am »

Is there anything new with the xPL plug-in?! I would be interested in it, but I don't have the skills to do it myself :-(

C'u Surfikus
Logged
Pages: [1]   Go Up