From a4035c18b578388d72e64d7e376b2ef424c38499 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 6 May 2021 23:42:52 -0500 Subject: [PATCH] Switch stream exit button to Play/Pause on Apple TV It appears it's no longer possible to get a double-press for the Menu button on tvOS 14.5 Fixes #456 --- .../StreamFrameViewController.m | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index a4d8e37d..e7a20280 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -24,8 +24,9 @@ TemporarySettings *_settings; NSTimer *_inactivityTimer; NSTimer *_statsUpdateTimer; - UITapGestureRecognizer *_menuGestureRecognizer; + UITapGestureRecognizer *_menuTapGestureRecognizer; UITapGestureRecognizer *_menuDoubleTapGestureRecognizer; + UITapGestureRecognizer *_playPauseTapGestureRecognizer; UITextView *_overlayView; UILabel *_stageLabel; UILabel *_tipLabel; @@ -55,6 +56,10 @@ Log(LOG_I, @"Menu double-pressed -- backing out of stream"); [self returnToMainFrame]; } +- (void)controllerPlayPauseButtonPressed:(id)sender { + Log(LOG_I, @"Play/Pause button pressed -- backing out of stream"); + [self returnToMainFrame]; +} #endif @@ -94,18 +99,23 @@ [_streamView setupStreamView:_controllerSupport interactionDelegate:self config:self.streamConfig]; #if TARGET_OS_TV - if (!_menuGestureRecognizer || !_menuDoubleTapGestureRecognizer) { - _menuGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonPressed:)]; - _menuGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)]; + if (!_menuTapGestureRecognizer || !_menuDoubleTapGestureRecognizer || !_playPauseTapGestureRecognizer) { + _menuTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonPressed:)]; + _menuTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)]; + _playPauseTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPlayPauseButtonPressed:)]; + _playPauseTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypePlayPause)]; + _menuDoubleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonDoublePressed:)]; _menuDoubleTapGestureRecognizer.numberOfTapsRequired = 2; - [_menuGestureRecognizer requireGestureRecognizerToFail:_menuDoubleTapGestureRecognizer]; + [_menuTapGestureRecognizer requireGestureRecognizerToFail:_menuDoubleTapGestureRecognizer]; _menuDoubleTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)]; } - [self.view addGestureRecognizer:_menuGestureRecognizer]; + [self.view addGestureRecognizer:_menuTapGestureRecognizer]; [self.view addGestureRecognizer:_menuDoubleTapGestureRecognizer]; + [self.view addGestureRecognizer:_playPauseTapGestureRecognizer]; + #else _exitSwipeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)]; _exitSwipeRecognizer.edges = UIRectEdgeLeft; @@ -119,7 +129,7 @@ [_tipLabel setUserInteractionEnabled:NO]; #if TARGET_OS_TV - [_tipLabel setText:@"Tip: Double tap the Menu button on the Apple TV Remote to disconnect from your PC"]; + [_tipLabel setText:@"Tip: Tap the Play/Pause button on the Apple TV Remote to disconnect from your PC"]; #else [_tipLabel setText:@"Tip: Swipe from the left edge to disconnect from your PC"]; #endif