Class MrpRemoteControl
- Namespace
- AppleTvControlLibrary.Mrp.RemoteControl
- Assembly
- AppleTvControlLibrary.Mrp.dll
Implementation of the MRP remote-control command surface: directional/menu/select HID keys, playback transport commands, seek, repeat/shuffle, and absolute volume.
public sealed class MrpRemoteControl
- Inheritance
-
MrpRemoteControl
- Inherited Members
Remarks
Initializes a new instance of the MrpRemoteControl class.
Constructors
MrpRemoteControl(MrpProtocol, MrpPlayerStateManager, HttpClient?)
Implementation of the MRP remote-control command surface: directional/menu/select HID keys, playback transport commands, seek, repeat/shuffle, and absolute volume.
public MrpRemoteControl(MrpProtocol protocol, MrpPlayerStateManager playerStateManager, HttpClient? httpClient = null)
Parameters
protocolMrpProtocolThe MRP protocol instance used to send/receive messages.
playerStateManagerMrpPlayerStateManagerThe player state manager used to look up command capabilities.
httpClientHttpClientThe HTTP client used to fetch remote artwork (e.g. iTunes-hosted artwork referenced by
artworkIdentifier/artworkURL). If not supplied, a default instance is created.
Remarks
Initializes a new instance of the MrpRemoteControl class.
Methods
BeginFastForward(CancellationToken)
Begin fast-forwarding through the current media.
public Task BeginFastForward(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
BeginRewind(CancellationToken)
Begins rewinding through the current media.
public Task BeginRewind(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Down(InputAction, CancellationToken)
Press key down.
public Task Down(InputAction action = InputAction.SingleTap, CancellationToken cancellationToken = default)
Parameters
actionInputActionThe type of press to perform.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
EndFastForward(CancellationToken)
Ends a previously started fast-forward.
public Task EndFastForward(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
EndRewind(CancellationToken)
Ends a previously started rewind.
public Task EndRewind(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
GetArtworkAsync(int, int, CancellationToken)
Fetches artwork for the currently playing item, mirroring pyatv's MrpMetadata.artwork():
checks a small identifier-keyed cache first, then attempts a remote (HTTP) fetch using
artworkIdentifier/artworkURL metadata, and falls back to an in-band MRP fetch
(GetLocalArtworkAsync(int, int, CancellationToken)) if the remote fetch does not produce a result. All
fetch failures (HTTP errors, malformed URL templates, cancelled/failed MRP round-trips) are
valid outcomes — not every item has artwork, and a device may reject the request — so they
are handled by returning null rather than propagating.
public Task<(byte[] Data, string? MimeType)?> GetArtworkAsync(int width = -1, int height = 400, CancellationToken cancellationToken = default)
Parameters
widthintThe requested artwork width, or -1 for no preference.
heightintThe requested artwork height, or -1 for no preference.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
- Task<(byte[] Data, string MimeType)?>
The artwork bytes and MIME type, or null if no artwork is available.
GetLocalArtworkAsync(int, int, CancellationToken)
Explicitly fetches artwork bytes for the currently playing item directly over MRP, bypassing the remote-URL fetch and cache used by GetArtworkAsync(int, int, CancellationToken).
public Task<(byte[] Data, string? MimeType)?> GetLocalArtworkAsync(int width = -1, int height = 400, CancellationToken cancellationToken = default)
Parameters
widthintThe requested artwork width, or -1 for no preference.
heightintThe requested artwork height, or -1 for no preference.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
- Task<(byte[] Data, string MimeType)?>
The artwork bytes and MIME type, or null if no artwork is available.
Home(InputAction, CancellationToken)
Press key home.
public Task Home(InputAction action = InputAction.SingleTap, CancellationToken cancellationToken = default)
Parameters
actionInputActionThe type of press to perform.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
HomeHold(CancellationToken)
Hold key home.
public Task HomeHold(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Left(InputAction, CancellationToken)
Press key left.
public Task Left(InputAction action = InputAction.SingleTap, CancellationToken cancellationToken = default)
Parameters
actionInputActionThe type of press to perform.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Menu(InputAction, CancellationToken)
Press key menu.
public Task Menu(InputAction action = InputAction.SingleTap, CancellationToken cancellationToken = default)
Parameters
actionInputActionThe type of press to perform.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Next(CancellationToken)
Press key next.
public Task Next(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Pause(CancellationToken)
Press key play.
public Task Pause(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Play(CancellationToken)
Press key play.
public Task Play(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
PlayPause(CancellationToken)
Toggle between play and pause.
public Task PlayPause(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Previous(CancellationToken)
Press key previous.
public Task Previous(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Right(InputAction, CancellationToken)
Press key right.
public Task Right(InputAction action = InputAction.SingleTap, CancellationToken cancellationToken = default)
Parameters
actionInputActionThe type of press to perform.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Select(InputAction, CancellationToken)
Press key select.
public Task Select(InputAction action = InputAction.SingleTap, CancellationToken cancellationToken = default)
Parameters
actionInputActionThe type of press to perform.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
SetPosition(int, CancellationToken)
Seek in the current playing media.
public Task SetPosition(int position, CancellationToken cancellationToken = default)
Parameters
positionintThe absolute position, in seconds.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
SetRepeat(RepeatState, CancellationToken)
Change repeat state.
public Task SetRepeat(RepeatState repeatState, CancellationToken cancellationToken = default)
Parameters
repeatStateRepeatStateThe repeat mode to set.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
SetShuffle(ShuffleState, CancellationToken)
Change shuffle mode to on or off.
public Task SetShuffle(ShuffleState shuffleState, CancellationToken cancellationToken = default)
Parameters
shuffleStateShuffleStateThe shuffle mode to set.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
SetVolume(string, float, CancellationToken)
Change volume on a device.
public Task SetVolume(string deviceUid, float volume, CancellationToken cancellationToken = default)
Parameters
deviceUidstringThe output device identifier.
volumefloatThe volume level, in the range 0.0-1.0.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
SkipBackward(double, CancellationToken)
Skip backwards a time interval. Skip interval is typically 15-30s, but is decided by the app.
public Task SkipBackward(double timeInterval = 0, CancellationToken cancellationToken = default)
Parameters
timeIntervaldoubleThe number of seconds to skip, or 0 to use the app's preferred interval.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
SkipForward(double, CancellationToken)
Skip forward a time interval. Skip interval is typically 15-30s, but is decided by the app.
public Task SkipForward(double timeInterval = 0, CancellationToken cancellationToken = default)
Parameters
timeIntervaldoubleThe number of seconds to skip, or 0 to use the app's preferred interval.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Stop(CancellationToken)
Press key stop.
public Task Stop(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Suspend(CancellationToken)
Suspend the device.
public Task Suspend(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
TopMenu(CancellationToken)
Go to main menu (long press menu).
public Task TopMenu(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
TurnOff(CancellationToken)
Turns the device "off": on tvOS this dismisses to the screensaver rather than a true power off (MRP has no dedicated power-off message; see the DeviceInfoMessage.logicalDeviceCount == 0 check pyatv uses to detect the resulting Off power state).
public Task TurnOff(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
TurnOn(CancellationToken)
Turn the device on. Unlike Wakeup(CancellationToken), which sends a "wakeup"
SEND_HID_EVENT_MESSAGE (HID usage-page/usage pair (1, 0x83), not a HID-protocol
transport), this sends the dedicated WAKE_DEVICE_MESSAGE protobuf message directly.
public Task TurnOn(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Up(InputAction, CancellationToken)
Press key up.
public Task Up(InputAction action = InputAction.SingleTap, CancellationToken cancellationToken = default)
Parameters
actionInputActionThe type of press to perform.
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
VolumeDown(CancellationToken)
Press key volume down.
public Task VolumeDown(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
VolumeUp(CancellationToken)
Press key volume up.
public Task VolumeUp(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.
Returns
Wakeup(CancellationToken)
Wake up the device.
public Task Wakeup(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that cancels the operation.