Install using nuget
Install-Package MPC-HC.Domain
- Play
- Pause
- Stop
- Set volume level
- Get all info from
/variables.html
- Open media file
- UnMute
- Mute
- ToggleMute
- Next
- Prev
- SetPosition
- ToggleFullscreen
With the help of the MPCHomeCinemaObserver
you can subscribe to the PropertyChanged
event.
This event will notify when the state of the MPC-HC changes (/varibales.html
) and rise the event.
The event cointains
- The old state
- The new state
- The property that changed as a enum.
As of now, this is how you create an instace of the commandService
and send request to the web interface.
var mpcHomeCinema = new MPCHomeCinema("http://localhost:13579");
var result = await mpcHomeCinema.PlayAsync();
if(result.ResultCode == ResultCode.Ok){
//we are good
Console.WriteLine($"{result.Info.FileName} is playing");
}
And if you want to listen for changes.
var mpcHcObserver = new MPCHomeCinemaObserver(mpcClient);
mpcHcObserver.PropertyChanged += (sender, args) =>
{
switch (args.Property)
{
case Property.File:
Console.WriteLine($"Property changed from {args.OldInfo.FileName}, -> {args.NewInfo.FileName}");
break;
case Property.State:
Console.WriteLine($"Property changed from {args.OldInfo.State}, -> {args.NewInfo.State}");
break;
case Property.Possition:
Console.WriteLine($"Property changed from {args.OldInfo.Position}, -> {args.NewInfo.Position}");
break;
default:
throw new ArgumentOutOfRangeException();
}
};
You need to enable the inbuilt web interface in the options.
There is a low test covrage due to bad implementation of the MPC-HC web interface. (It returns no response but a 302, no matter what you throw at it.)
This is solved by running realtime integration test and checking the /variables.html
after each request.