mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 06:01:13 +00:00
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
This commit is contained in:
@@ -24,8 +24,9 @@
|
|||||||
TemporarySettings *_settings;
|
TemporarySettings *_settings;
|
||||||
NSTimer *_inactivityTimer;
|
NSTimer *_inactivityTimer;
|
||||||
NSTimer *_statsUpdateTimer;
|
NSTimer *_statsUpdateTimer;
|
||||||
UITapGestureRecognizer *_menuGestureRecognizer;
|
UITapGestureRecognizer *_menuTapGestureRecognizer;
|
||||||
UITapGestureRecognizer *_menuDoubleTapGestureRecognizer;
|
UITapGestureRecognizer *_menuDoubleTapGestureRecognizer;
|
||||||
|
UITapGestureRecognizer *_playPauseTapGestureRecognizer;
|
||||||
UITextView *_overlayView;
|
UITextView *_overlayView;
|
||||||
UILabel *_stageLabel;
|
UILabel *_stageLabel;
|
||||||
UILabel *_tipLabel;
|
UILabel *_tipLabel;
|
||||||
@@ -55,6 +56,10 @@
|
|||||||
Log(LOG_I, @"Menu double-pressed -- backing out of stream");
|
Log(LOG_I, @"Menu double-pressed -- backing out of stream");
|
||||||
[self returnToMainFrame];
|
[self returnToMainFrame];
|
||||||
}
|
}
|
||||||
|
- (void)controllerPlayPauseButtonPressed:(id)sender {
|
||||||
|
Log(LOG_I, @"Play/Pause button pressed -- backing out of stream");
|
||||||
|
[self returnToMainFrame];
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -94,18 +99,23 @@
|
|||||||
[_streamView setupStreamView:_controllerSupport interactionDelegate:self config:self.streamConfig];
|
[_streamView setupStreamView:_controllerSupport interactionDelegate:self config:self.streamConfig];
|
||||||
|
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
if (!_menuGestureRecognizer || !_menuDoubleTapGestureRecognizer) {
|
if (!_menuTapGestureRecognizer || !_menuDoubleTapGestureRecognizer || !_playPauseTapGestureRecognizer) {
|
||||||
_menuGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonPressed:)];
|
_menuTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonPressed:)];
|
||||||
_menuGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)];
|
_menuTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)];
|
||||||
|
|
||||||
|
_playPauseTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPlayPauseButtonPressed:)];
|
||||||
|
_playPauseTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypePlayPause)];
|
||||||
|
|
||||||
_menuDoubleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonDoublePressed:)];
|
_menuDoubleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonDoublePressed:)];
|
||||||
_menuDoubleTapGestureRecognizer.numberOfTapsRequired = 2;
|
_menuDoubleTapGestureRecognizer.numberOfTapsRequired = 2;
|
||||||
[_menuGestureRecognizer requireGestureRecognizerToFail:_menuDoubleTapGestureRecognizer];
|
[_menuTapGestureRecognizer requireGestureRecognizerToFail:_menuDoubleTapGestureRecognizer];
|
||||||
_menuDoubleTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)];
|
_menuDoubleTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.view addGestureRecognizer:_menuGestureRecognizer];
|
[self.view addGestureRecognizer:_menuTapGestureRecognizer];
|
||||||
[self.view addGestureRecognizer:_menuDoubleTapGestureRecognizer];
|
[self.view addGestureRecognizer:_menuDoubleTapGestureRecognizer];
|
||||||
|
[self.view addGestureRecognizer:_playPauseTapGestureRecognizer];
|
||||||
|
|
||||||
#else
|
#else
|
||||||
_exitSwipeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)];
|
_exitSwipeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)];
|
||||||
_exitSwipeRecognizer.edges = UIRectEdgeLeft;
|
_exitSwipeRecognizer.edges = UIRectEdgeLeft;
|
||||||
@@ -119,7 +129,7 @@
|
|||||||
[_tipLabel setUserInteractionEnabled:NO];
|
[_tipLabel setUserInteractionEnabled:NO];
|
||||||
|
|
||||||
#if TARGET_OS_TV
|
#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
|
#else
|
||||||
[_tipLabel setText:@"Tip: Swipe from the left edge to disconnect from your PC"];
|
[_tipLabel setText:@"Tip: Swipe from the left edge to disconnect from your PC"];
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user