Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Added documentation on how to use MpcHc observer class.
  • Loading branch information
Zexuz authored Aug 2, 2018
1 parent eb061ee commit fe8837c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ Install using nuget
* Prev
* SetPosition

## Events
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.


## Usage

Expand All @@ -32,6 +41,30 @@ if(result.ResultCode == ResultCode.Ok){
}
```

And if you want to listen for changes.

```csharp
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();
}
};
```


## Set up MPC-HC

Expand Down

0 comments on commit fe8837c

Please sign in to comment.