- wiimp.zip
- WMPControlYJW
- _UpgradeReport_Files
- Backup
- UpgradeLog.XML
- WiimoteLib
- WiiMP
- WMPControlYJW.sln
- WMPControlYJW.suo
- WMPControlYJW
|
/*
* Source Code By Yousef Jamal Wadi
* WMPControlYJW Library Created by Yousef Jamal Wadi
* Feel Free To Distribute as you like ;)
*
* Yousef Jamal Wadi
* Software Arch. and Engineer
* German Jordanian University
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Runtime.InteropServices; // To Work On Introping WMP
namespace WMPControlYJW
{
public class WMPYJW
{
private Int32 wmHandle;
private const int WM_COMMAND = 0x111;
//Commands for Windows Media Player
#region Commands
private const int E_B = 0x00000000;
private const int WM_Play = 0x00014978 ;
private const int WM_Stop = 0x00014979 ;
private const int WM_Next = 0x0001497B ;
private const int WM_Mute = 0x00014981 ;
private const int WM_VUp = 0x0001497F ;
private const int WM_VDown = 0x00014980 ;
private const int WM_Prev = 0x0001497A ;
private const int WM_FastF = 0x0001497D;
#endregion
// Functions to deal with the API
#region WIN32 Functions
////Dealing with the WIN32////////////////
[DllImport("User32.dll")]
public static extern int FindWindow(string strClassName, string strWindowName);
[DllImport("User32.dll")]
public static extern int FindWindowEx(int hwndParent, int hwndChildAfter, string strClassName, string strWindowName);
[DllImport("User32.dll")]
public static extern Int32 SendMessage(int hWnd,int Msg,int wParam,[MarshalAs(UnmanagedType.LPStr)] string lParam);
[DllImport("User32.dll")]
public static extern Int32 SendMessage(int hWnd,int Msg,int wParam,int lParam);
///////////////
#endregion
//Empty Constructor
public WMPYJW()
{
}
// Connects the library with the Windows Media Player Instance to send commands
#region Connect WMP
public string ConnectWMP()
{
try
{
wmHandle = FindWindow("WMPLayerApp", "Windows Media Player");
return(null);
}
catch (Exception e)
{
return (e.Message.ToString());
}
}
#endregion
// Sends the play command to the open WMP Window
#region Play Function
public string Play()
{
try
{
SendMessage(wmHandle, WM_COMMAND, WM_Play,E_B);
return (null);
}
catch (Exception e)
{
return (e.Message.ToString());
}
}
#endregion //Function To Send Play Command To WMP
// Sends the Stop command to the open WMP Window
#region Stop Function
public string Stop()
{
try
{
SendMessage(wmHandle, WM_COMMAND, WM_Stop, E_B);
return (null);
}
catch (Exception e)
{
return (e.Message.ToString());
}
}
#endregion
// Send the Next command to the open WMP Window
#region Next Function
public string Next()
{
try
{
SendMessage(wmHandle, WM_COMMAND, WM_Next, E_B);
return (null);
}
catch (Exception e)
{
return (e.Message.ToString());
}
}
#endregion
// Send the mute command to the open WMP Window
#region Mute Function
public string Mute()
{
try
{
SendMessage(wmHandle, WM_COMMAND, WM_Mute, E_B);
return (null);
}
catch (Exception e)
{
return (e.Message.ToString());
}
}
#endregion
// Send Volume down command to the open WMP Window
#region Volume Down Function
public string Volume_Down()
{
try
{
SendMessage(wmHandle, WM_COMMAND, WM_VDown, E_B);
return (null);
}
catch (Exception e)
{
return (e.Message.ToString());
}
}
#endregion
// Sends Volume Up command to the open WMP Window
#region Volume Up Function
public string Volume_Up()
{
try
{
SendMessage(wmHandle, WM_COMMAND, WM_VUp, E_B);
return (null);
}
catch (Exception e)
{
return (e.Message.ToString());
}
}
#endregion
// Sends the Volume Down command to the open WMP Window
#region Previous Function
public string Previous()
{
try
{
SendMessage(wmHandle, WM_COMMAND, WM_Prev, E_B);
return (null);
}
catch (Exception e)
{
return (e.Message.ToString());
}
}
#endregion
// Sends the Fast Forward command to the open WMP Window
#region Fast Forward Function
public string Fast_Forward()
{
try
{
SendMessage(wmHandle, WM_COMMAND, WM_FastF, E_B);
return (null);
}
catch (Exception e)
{
return (e.Message.ToString());
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.