MJAutomation: Difference between revisions

From wiki.jriver.com
Jump to navigation Jump to search
No edit summary
 
(20 intermediate revisions by 3 users not shown)
Line 27: Line 27:
===MJMixerAutomation * GetMJMixer()===
===MJMixerAutomation * GetMJMixer()===
'''Description:''' gets a [[MJMixerAutomation]] interface<br>
'''Description:''' gets a [[MJMixerAutomation]] interface<br>
'''Return Value:''' [[MJMixerAutomation]] interface
'''Return Value:''' [[MJMixerAutomation]] interface<br>
''' C# Example:
// Use this in the Init of MC
private void setEQOnOff ()
{
this.checkBoxEQOnOff.Checked = mcRef.GetMJMixer ().EQOn;
}
// The 'checkBoxEQOnOff_CheckedChanged' is automatically generated by Visual Studio 2005 upon doubleclick
private void checkBoxEQOnOff_CheckedChanged ( object sender, EventArgs e )
{
mcRef.GetMJMixer ().EQOn = checkBoxEQOnOff.Checked;
}


===MJVersionAutomation * GetVersion()===
===MJVersionAutomation * GetVersion()===
Line 54: Line 65:
'''Parameters:'''
'''Parameters:'''
* '''nWindowHandle''': handle to the specific window (convert HWND to long)
* '''nWindowHandle''': handle to the specific window (convert HWND to long)
* '''bSkin''': TRUE - enables skinning of the specified window, FALSE - disables skinning for the window.
* '''bSkin''': TRUE - enables skinning of the specified window, FALSE - disables skinning for the window.

Skinning is permanently disabled for many windows created outside of C++ (such as Visual Basic, C# or .NET).
If this function appears to have no effect, that is probably the cause.


===MJInternetAutomation * GetInternet()===
===MJInternetAutomation * GetInternet()===
Line 61: Line 75:


===number GetSkinInfo(string strItem, string strAttribute)===
===number GetSkinInfo(string strItem, string strAttribute)===
'''Description:''' Retrieves information about current skin.<br>
'''Description:''' Retrieves information about current skin. The Item and Attributes are described in [[MEGAMorphis]].<br>
'''Parameters:'''
'''Parameters:'''
* '''strItem''': item name
* '''strItem''': item name
Line 70: Line 84:
GetSkinInfo("StatusBar", "BackColor");
GetSkinInfo("StatusBar", "BackColor");


Example translating a MC Color into a C# Color Object:
'''C# Example: translating a MC Color into a Color Object:
private Color getColor(String strElement, String strProperty)
private Color getColor(String strItem, String strAttribute)
{
{
int intColor;
int intColor;
Line 78: Line 92:
int intB;
int intB;
intColor = mcRef.GetSkinInfo ( strElement, strProperty );
intColor = mcRef.GetSkinInfo ( strItem, strAttribute );
intR = intColor & 255;
if (intColor != -1)
{
intG = (intColor >> 8) & 255;
intB = (intColor >> 16) & 255;
intR = intColor & 255;
intG = (intColor >> 8) & 255;
intB = (intColor >> 16) & 255;
return Color.FromArgb ( intR, intG, intB );
return Color.FromArgb ( intR, intG, intB );
}
else
{
// Return a default Color if not found!
return Color.LightGray;
}
}
}
...
Panel.BackColor = getColor ( "Tree", "BackColor" );


===number IsPurchased()===
===number IsPurchased()===
'''Description:''' Retrieves registration information<br>
'''Description:''' Retrieves registration information<br>
'''Return Value:''' if Media Center is purchased return value will be -1. The value will be equal to 0 if trial period expired but the program was not purchased. If the value > 0 the function returned number of days left in the trial period.
'''Return Value:''' if Media Center is purchased return value will be -1. The value will be equal to 0 if trial period expired but the program was not purchased. If the value > 0 the function returned number of days left in the trial period.

===string ProcessWebService(string, string)===
'''Description:'''
'''Return Value:'''

===number ProperlyMarshaled()===
'''Description:'''
'''Return Value:'''


===MJViewItemAutomation * GetViewItem(string strPath)===
===MJViewItemAutomation * GetViewItem(string strPath)===
Line 161: Line 196:
'''Description:''' Gets a CD/DVD Automation interface<br>
'''Description:''' Gets a CD/DVD Automation interface<br>
'''Return Value:''' [[MJCDDVDAutomation]] Interface
'''Return Value:''' [[MJCDDVDAutomation]] Interface

===void GetLibrary(string *Name, string *Path)===
'''Description:''' Returns the name and directory of the currently loaded library.<br>
'''Parameters:'''
* '''Name''': The name of the library (returned).
* '''Path''': The directory of the library (returned).

===long CreateInterface(string Name, string Parameter)===
'''Description:''' Returns an interface object, specified by Name with argument Parameter.<br>
'''Parameters:'''
* '''Name''': The name of the interface.
* '''Parameter''': A parameter.
Returns an interface object. Name must be '''IVisData''' or '''IVisRedrawHelper'''. Parameter is used for IVisData and is the zone number of the plug-in. See the [[Display Plug-in SDK]] for more details. Media Center 12.0.405 required.


==Properties==
==Properties==
===number IVersion() (read only)===
===number IVersion() (read only)===
'''Description:''' retrieves version of MC Automation interface. (2 is current version)<br>
'''Description:''' retrieves version of MC Automation interface. (2 is current version)<br>

[[Category:COM Automation]]

Latest revision as of 05:37, 4 May 2015

core object... provides access to all other objects

Functions[edit]

MJPlaybackAutomation * GetPlayback()[edit]

Description: gets a MJPlaybackAutomation interface
Return Value: MJPlaybackAutomation interface

MJFilesAutomation * Search(string strSearch)[edit]

Description: gets a MJFilesAutomation interface for the files matching the specified search
Parameters:

  • strSearch: the search string to use... can be any search accepted by Media Center

Return Value: MJFilesAutomation interface

MJCurPlaylistAutomation * GetCurPlaylist()[edit]

Description: gets a MJCurPlaylistAutomation interface
Return Value: MJCurPlaylistAutomation interface

MJPlaylistsAutomation * GetPlaylists()[edit]

Description: gets a MJPlaylistsAutomation interface for all of the existing playlists
Return Value: MJPlaylistsAutomation interface

MJSchemeAutomation * GetViewScheme(string strPath)[edit]

Description: gets a MJSchemeAutomation interface for the given library path
Parameters:

  • strPath: the path to the view scheme delimited by backslashes. (i.e. "Media Library\Artist/Album\Metallica")

Return Value: MJSchemeAutomation interface

MJMixerAutomation * GetMJMixer()[edit]

Description: gets a MJMixerAutomation interface
Return Value: MJMixerAutomation interface
C# Example:

// Use this in the Init of MC
private void setEQOnOff ()
{
     this.checkBoxEQOnOff.Checked = mcRef.GetMJMixer ().EQOn;
}
// The 'checkBoxEQOnOff_CheckedChanged' is automatically generated by Visual Studio 2005 upon doubleclick
private void checkBoxEQOnOff_CheckedChanged ( object sender, EventArgs e )
{
    mcRef.GetMJMixer ().EQOn = checkBoxEQOnOff.Checked;
}

MJVersionAutomation * GetVersion()[edit]

Description: gets a MJVersionAutomation interface.
Return Value: MJVersionAutomation interface

MJFileAutomation * GetFile(string strFilename)[edit]

Description: gets a MJFileAutomation interface for the given file.
Parameters:

  • strFilename: the path to the file.

Return Value: MJFileAutomation interface

MJFileAutomation * GetFileByKey(number nKey)[edit]

Description: gets a MJFileAutomation interface for the file denoted by the key.
Parameters:

  • nKey: the key of a file.

Return Value: MJFileAutomation interface

void EnableSkinning(number bEnable)[edit]

Description: Enables and disabled Media Center skinning. Useful in case when MC could not skin plug-in window correctly.
Parameters:

  • bEnable: TRUE - enable skinning, FALSE - disable.

void SkinWindow(number nWindowHandle, boolean bSkin)[edit]

Description: Skins or removes skinning from the specified window.
Parameters:

  • nWindowHandle: handle to the specific window (convert HWND to long)
  • bSkin: TRUE - enables skinning of the specified window, FALSE - disables skinning for the window.

Skinning is permanently disabled for many windows created outside of C++ (such as Visual Basic, C# or .NET). If this function appears to have no effect, that is probably the cause.

MJInternetAutomation * GetInternet()[edit]

Description: gets a MJInternetAutomation interface.
Return Value: MJInternetAutomation interface

number GetSkinInfo(string strItem, string strAttribute)[edit]

Description: Retrieves information about current skin. The Item and Attributes are described in MEGAMorphis.
Parameters:

  • strItem: item name
  • strAttribute: attribute name.

Return Value: value of the specified skin item. -1 if the info was not found.
Examples:

GetSkinInfo("Tree", "TextColor");
GetSkinInfo("StatusBar", "BackColor");

C# Example: translating a MC Color into a Color Object:

private Color getColor(String strItem, String strAttribute)
{
    int intColor;
    int intR;
    int intG;
    int intB;

    intColor = mcRef.GetSkinInfo ( strItem, strAttribute );

    if (intColor != -1)
    {
        intR = intColor & 255;
        intG = (intColor >> 8) & 255;
        intB = (intColor >> 16) & 255;

        return Color.FromArgb ( intR, intG, intB );
    }
    else
    {
        // Return a default Color if not found!

        return Color.LightGray;
    }
}

...

     Panel.BackColor = getColor ( "Tree", "BackColor" );

number IsPurchased()[edit]

Description: Retrieves registration information
Return Value: if Media Center is purchased return value will be -1. The value will be equal to 0 if trial period expired but the program was not purchased. If the value > 0 the function returned number of days left in the trial period.

string ProcessWebService(string, string)[edit]

Description: Return Value:

number ProperlyMarshaled()[edit]

Description: Return Value:

MJViewItemAutomation * GetViewItem(string strPath)[edit]

Description: gets a MJViewItemAutomation interface for the given file.
Parameters:

  • strPath: the path to a view item.

Return Value: MJViewItemAutomation interface

number GetWindowHandle()[edit]

Description: Retrieves handle to Media Center's main window
Return Value: HWND to main application window.

void ShowProgram(number bShow)[edit]

Description: Changes visibility state of the program.
Parameters:

  • bShow: 1 - show the app, 0 - hide.

MJFileAutomation * ImportFile(string strFilename)[edit]

Description: imports a new file into Media Center
Parameters:

  • strFilename: the path to the file.

Return Value: MJFileAutomation interface

void SetGlobalFocusedWindow(number hwndNew, number bInvalidateNew)[edit]

Description: Sets the focus to the new window.
Parameters:

  • hwndNew: the handle of the window
  • bInvalidateNew: Invalidate the new window so it knows the focus changed

MJFieldsAutomation * GetFields()[edit]

Description: gets a MJFieldsAutomation interface
Return Value: MJFieldsAutomation interface

MJZonesAutomation * GetZones()[edit]

Description: gets a MJZonesAutomation interface
Return Value: MJZonesAutomation interface

MJFilesAutomation * CreateFiles()[edit]

Description: gets a MJFilesAutomation interface with no files
Return Value: MJFilesAutomation interface

MJTaskAutomation * GetTask(string strTask)[edit]

Description: gets a MJTaskAutomation interface.
Parameters:

  • strTask: the name of the task.

Return Value: MJTaskAutomation interface

MJServicesAutomation * GetServices()[edit]

Description: gets a MJServicesAutomation interface.
Return Value: MJServicesAutomation interface

void ReportEvent(string Name, string Data)[edit]

Description: Reports an event.
Parameters:

  • Name: the name of the event
  • Data: extra data.

IMJPlaylistAutomation *GetPlaylistByID(number nID)[edit]

Description: Gets a playlist
Parameters:

  • nID: the ID of the playlist

Return Value: MJPlaylistAutomation interface (see below)

void RegisterWindowWithRouter(number hwndRegister, number nRegisterState)[edit]

Description: Register or unregister a window with the router
Parameters:

  • hwndRegister: Handle of the window to register
  • nRegisterState: TRUE for register, FALSE for unregister

IMJCDDVDAutomation *GetCDDVD()[edit]

Description: Gets a CD/DVD Automation interface
Return Value: MJCDDVDAutomation Interface

void GetLibrary(string *Name, string *Path)[edit]

Description: Returns the name and directory of the currently loaded library.
Parameters:

  • Name: The name of the library (returned).
  • Path: The directory of the library (returned).

long CreateInterface(string Name, string Parameter)[edit]

Description: Returns an interface object, specified by Name with argument Parameter.
Parameters:

  • Name: The name of the interface.
  • Parameter: A parameter.

Returns an interface object. Name must be IVisData or IVisRedrawHelper. Parameter is used for IVisData and is the zone number of the plug-in. See the Display Plug-in SDK for more details. Media Center 12.0.405 required.

Properties[edit]

number IVersion() (read only)[edit]

Description: retrieves version of MC Automation interface. (2 is current version)