diff --git a/pyatv/const.py b/pyatv/const.py index 2cdc5394e..da7db2498 100644 --- a/pyatv/const.py +++ b/pyatv/const.py @@ -305,6 +305,12 @@ class FeatureName(Enum): WakeUp = 18 """Wake up device (deprecated; use Power.turn_on).""" + FastForward = 63 + """Fast Forward.""" + + Rewind = 64 + """Rewind.""" + SkipForward = 36 """Skip forward a time interval.""" diff --git a/pyatv/core/facade.py b/pyatv/core/facade.py index 755e72e4e..700e8b759 100644 --- a/pyatv/core/facade.py +++ b/pyatv/core/facade.py @@ -190,6 +190,16 @@ async def screensaver(self) -> None: """Activate screen saver..""" return await self.relay("screensaver")() + @shield.guard + async def fast_forward(self) -> None: + """Fast Forward..""" + return await self.relay("fast_forward")() + + @shield.guard + async def rewind(self) -> None: + """Rewind..""" + return await self.relay("rewind")() + class FacadeMetadata(Relayer, interface.Metadata): """Facade implementation for retrieving metadata from an Apple TV.""" diff --git a/pyatv/interface.py b/pyatv/interface.py index 4affd4bb9..5edc11dea 100644 --- a/pyatv/interface.py +++ b/pyatv/interface.py @@ -451,6 +451,16 @@ async def screensaver(self) -> None: """Activate screen saver..""" raise exceptions.NotSupportedError() + @feature(63, "FastForward", "Fast Forward.") + async def fast_forward(self, action: InputAction = InputAction.SingleTap) -> None: + """Press key fast forward.""" + raise exceptions.NotSupportedError() + + @feature(64, "Rewind", "Rewind.") + async def rewind(self, action: InputAction = InputAction.SingleTap) -> None: + """Press key rewind.""" + raise exceptions.NotSupportedError() + # TODO: Should be made into a dataclass when support for 3.6 is dropped class Playing(ABC): diff --git a/pyatv/protocols/companion/__init__.py b/pyatv/protocols/companion/__init__.py index ad7e5f58d..78dd0b09b 100644 --- a/pyatv/protocols/companion/__init__.py +++ b/pyatv/protocols/companion/__init__.py @@ -106,6 +106,8 @@ class MediaControlFlags(IntFlag): FeatureName.SetVolume: MediaControlFlags.Volume, FeatureName.SkipForward: MediaControlFlags.SkipForward, FeatureName.SkipBackward: MediaControlFlags.SkipBackward, + FeatureName.FastForward: MediaControlFlags.FastForward, + FeatureName.Rewind: MediaControlFlags.Rewind } SUPPORTED_FEATURES = set( @@ -126,6 +128,8 @@ class MediaControlFlags(IntFlag): FeatureName.Left, FeatureName.Right, FeatureName.Select, + FeatureName.FastForward, + FeatureName.Rewind, FeatureName.Menu, FeatureName.Home, FeatureName.VolumeUp, @@ -334,6 +338,14 @@ async def previous(self) -> None: """Press key previous.""" await self.api.mediacontrol_command(MediaControlCommand.PreviousTrack) + async def fast_forward(self) -> None: + """Press key fast forward.""" + await self.api.mediacontrol_command(MediaControlCommand.FastForwardBegin) + + async def rewind(self) -> None: + """Press key rewind.""" + await self.api.mediacontrol_command(MediaControlCommand.RewindBegin) + async def channel_up(self) -> None: """Select next channel.""" await self._press_button(HidCommand.ChannelIncrement) @@ -590,4 +602,4 @@ def _device_info() -> Dict[str, Any]: def pair(core: Core, **kwargs) -> PairingHandler: """Return pairing handler for protocol.""" - return CompanionPairingHandler(core, **kwargs) + return CompanionPairingHandler(core, **kwargs) \ No newline at end of file diff --git a/tests/protocols/companion/test_companion_functional.py b/tests/protocols/companion/test_companion_functional.py index afd87a933..388363e64 100644 --- a/tests/protocols/companion/test_companion_functional.py +++ b/tests/protocols/companion/test_companion_functional.py @@ -39,6 +39,8 @@ FeatureName.Previous, FeatureName.SkipForward, FeatureName.SkipBackward, + FeatureName.FastForward, + FeatureName.Rewind, FeatureName.Volume, FeatureName.SetVolume, ]