Commit 713ee565 authored by Felix Paul Kühne's avatar Felix Paul Kühne

playback: fix vout behavior when app moves back and forth between active,...

playback: fix vout behavior when app moves back and forth between active, background and active states (closes #14795)

(cherry picked from commit 2cfb76550c2eb2eced514956a06d853fbf21604b)
parent cb5cc7e9
...@@ -217,6 +217,9 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -217,6 +217,9 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
[_videoView removeFromSuperview]; [_videoView removeFromSuperview];
_videoView = nil; _videoView = nil;
} }
VLCPlayerDisplayController *pdc = [(VLCAppDelegate *)[UIApplication sharedApplication].delegate playerDisplayController];
if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeMiniplayer) {
_videoView = [[UIView alloc] initWithFrame:_artworkView.frame]; _videoView = [[UIView alloc] initWithFrame:_artworkView.frame];
[_videoView setClipsToBounds:YES]; [_videoView setClipsToBounds:YES];
[_videoView addGestureRecognizer:_artworkTapRecognizer]; [_videoView addGestureRecognizer:_artworkTapRecognizer];
...@@ -224,6 +227,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -224,6 +227,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
[self addSubview:_videoView]; [self addSubview:_videoView];
controller.videoOutputView = _videoView; controller.videoOutputView = _videoView;
} }
}
NSString *metaDataString; NSString *metaDataString;
if (artist) if (artist)
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
#import "UIDevice+VLC.h" #import "UIDevice+VLC.h"
#import "VLCTimeNavigationTitleView.h" #import "VLCTimeNavigationTitleView.h"
#import "VLCPlayerDisplayController.h"
#import "VLCAppDelegate.h"
#import "VLCStatusLabel.h" #import "VLCStatusLabel.h"
#define FORWARD_SWIPE_DURATION 30 #define FORWARD_SWIPE_DURATION 30
...@@ -226,6 +227,10 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -226,6 +227,10 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
name:UIScreenDidDisconnectNotification object:nil]; name:UIScreenDidDisconnectNotification object:nil];
[center addObserver:self selector:@selector(screenBrightnessChanged:) [center addObserver:self selector:@selector(screenBrightnessChanged:)
name:UIScreenBrightnessDidChangeNotification object:nil]; name:UIScreenBrightnessDidChangeNotification object:nil];
[center addObserver:self
selector:@selector(appBecameActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
_playingExternallyTitle.text = NSLocalizedString(@"PLAYING_EXTERNALLY_TITLE", nil); _playingExternallyTitle.text = NSLocalizedString(@"PLAYING_EXTERNALLY_TITLE", nil);
_playingExternallyDescription.text = NSLocalizedString(@"PLAYING_EXTERNALLY_DESC", nil); _playingExternallyDescription.text = NSLocalizedString(@"PLAYING_EXTERNALLY_DESC", nil);
...@@ -1536,6 +1541,19 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1536,6 +1541,19 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
self.brightnessSlider.value = [(UIScreen *)[[UIScreen screens] firstObject] brightness] * 2.; self.brightnessSlider.value = [(UIScreen *)[[UIScreen screens] firstObject] brightness] * 2.;
} }
- (void)appBecameActive:(NSNotification *)aNotification
{
VLCPlayerDisplayController *pdc = [(VLCAppDelegate *)[UIApplication sharedApplication].delegate playerDisplayController];
if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeFullscreen) {
VLCPlaybackController *vpc = self.playbackController;
[vpc recoverDisplayedMetadata];
if (vpc.videoOutputView != self.movieView) {
vpc.videoOutputView = nil;
vpc.videoOutputView = self.movieView;
}
}
}
#pragma mark - playback view #pragma mark - playback view
- (IBAction)playbackSliderAction:(UISlider *)sender - (IBAction)playbackSliderAction:(UISlider *)sender
{ {
......
...@@ -37,6 +37,7 @@ NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPl ...@@ -37,6 +37,7 @@ NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPl
BOOL _playerIsSetup; BOOL _playerIsSetup;
BOOL _playbackFailed; BOOL _playbackFailed;
BOOL _shouldResumePlaying; BOOL _shouldResumePlaying;
BOOL _shouldResumePlayingAfterInteruption;
NSTimer *_sleepTimer; NSTimer *_sleepTimer;
NSArray *_aspectRatios; NSArray *_aspectRatios;
...@@ -711,15 +712,15 @@ NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPl ...@@ -711,15 +712,15 @@ NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPl
{ {
if ([_mediaPlayer isPlaying]) { if ([_mediaPlayer isPlaying]) {
[_mediaPlayer pause]; [_mediaPlayer pause];
_shouldResumePlaying = YES; _shouldResumePlayingAfterInteruption = YES;
} }
} }
- (void)endInterruption - (void)endInterruption
{ {
if (_shouldResumePlaying) { if (_shouldResumePlayingAfterInteruption) {
[_mediaPlayer play]; [_mediaPlayer play];
_shouldResumePlaying = NO; _shouldResumePlayingAfterInteruption = NO;
} }
} }
...@@ -1114,12 +1115,6 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(MPRemoteCommandCente ...@@ -1114,12 +1115,6 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(MPRemoteCommandCente
{ {
[self _savePlaybackState]; [self _savePlaybackState];
_preBackgroundWrapperView = _videoOutputViewWrapper;
[self setVideoOutputView:nil];
if (_mediaPlayer.audioTrackIndexes.count > 0)
_mediaPlayer.currentVideoTrackIndex = -1;
if (![[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingContinueAudioInBackgroundKey] boolValue]) { if (![[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingContinueAudioInBackgroundKey] boolValue]) {
if ([_mediaPlayer isPlaying]) { if ([_mediaPlayer isPlaying]) {
[_mediaPlayer pause]; [_mediaPlayer pause];
...@@ -1130,7 +1125,11 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(MPRemoteCommandCente ...@@ -1130,7 +1125,11 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(MPRemoteCommandCente
- (void)applicationDidEnterBackground:(NSNotification *)notification - (void)applicationDidEnterBackground:(NSNotification *)notification
{ {
_shouldResumePlaying = NO; _preBackgroundWrapperView = _videoOutputViewWrapper;
[self setVideoOutputView:nil];
if (_mediaPlayer.audioTrackIndexes.count > 0)
_mediaPlayer.currentVideoTrackIndex = -1;
} }
- (void)applicationDidBecomeActive:(NSNotification *)notification - (void)applicationDidBecomeActive:(NSNotification *)notification
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment