Commit 5c6cfb36 authored by Felix Paul Kühne's avatar Felix Paul Kühne

playback: retain window-state in background mode and fix black screen when...

playback: retain window-state in background mode and fix black screen when coming back (fixes #14686, #14687)
parent 04e9383f
......@@ -33,7 +33,7 @@
- (void)cleanCache;
- (void)presentMovieViewController;
- (void)presentMovieViewControllerAnimated:(BOOL)animated;
- (void)openMediaFromManagedObject:(NSManagedObject *)file;
- (void)openMovieFromURL:(NSURL *)url;
- (void)openMovieWithExternalSubtitleFromURL:(NSURL *)url externalSubURL:(NSString *)SubtitlePath;
......
......@@ -51,6 +51,7 @@
BOOL _passcodeValidated;
BOOL _isRunningMigration;
BOOL _isComingFromHandoff;
BOOL _presentingMovieController;
}
@property (nonatomic, strong) VLCMovieViewController *movieViewController;
......@@ -316,6 +317,10 @@ continueUserActivity:(NSUserActivity *)userActivity
- (void)applicationWillResignActive:(UIApplication *)application
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
_presentingMovieController = vpc.presentingMovieViewController;
[vpc destroyCurrentViewController];
_passcodeValidated = NO;
[self validatePasscode];
[[MLMediaLibrary sharedMediaLibrary] applicationWillExit];
......@@ -331,11 +336,9 @@ continueUserActivity:(NSUserActivity *)userActivity
}
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
if (!vpc.audioOnlyPlaybackSession) {
if (vpc.isPlaying && !self.movieViewController.presentingViewController)
[self presentMovieViewController];
} else
if (!vpc.audioOnlyPlaybackSession && _presentingMovieController)
[self presentMovieViewControllerAnimated:NO];
else
[self.playlistViewController displayMiniPlaybackViewIfNeeded];
}
......@@ -554,7 +557,7 @@ continueUserActivity:(NSUserActivity *)userActivity
#pragma mark - playback view handling
- (void)presentMovieViewController
- (void)presentMovieViewControllerAnimated:(BOOL)animated
{
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
return;
......@@ -563,7 +566,7 @@ continueUserActivity:(NSUserActivity *)userActivity
UINavigationController *navCon = [[VLCPlaybackNavigationController alloc] initWithRootViewController:self.movieViewController];
[self.movieViewController prepareForMediaPlayback:[VLCPlaybackController sharedInstance]];
navCon.modalPresentationStyle = UIModalPresentationFullScreen;
[self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
[self.window.rootViewController presentViewController:navCon animated:animated completion:nil];
}
- (void)openMediaFromManagedObject:(NSManagedObject *)mediaObject
......@@ -578,7 +581,7 @@ continueUserActivity:(NSUserActivity *)userActivity
[vpc playMediaLibraryObject:mediaObject];
if (retainFullscreenPlayback)
[self presentMovieViewController];
[self presentMovieViewControllerAnimated:YES];
}
- (void)openMovieFromURL:(NSURL *)url
......
......@@ -108,7 +108,7 @@
[VLCPlaybackController sharedInstance].videoOutputView = nil;
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate presentMovieViewController];
[appDelegate presentMovieViewControllerAnimated:YES];
}
- (void)setupForWork
......
......@@ -85,4 +85,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)setNeedsMetadataUpdate;
- (void)destroyCurrentViewController;
@end
......@@ -356,8 +356,7 @@
else if (self.successCallback)
[[UIApplication sharedApplication] openURL:self.successCallback];
if ([self.delegate respondsToSelector:@selector(presentingViewControllerShouldBeClosed:)])
[self.delegate presentingViewControllerShouldBeClosed:self];
[self destroyCurrentViewController];
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = nil;
[self unsubscribeFromRemoteCommand];
......@@ -481,8 +480,7 @@
[self stopPlayback];
} else if ((currentState == VLCMediaPlayerStateEnded || currentState == VLCMediaPlayerStateStopped) && _listPlayer.repeatMode == VLCDoNotRepeat) {
if ([_listPlayer.mediaList indexOfMedia:_mediaPlayer.media] == _listPlayer.mediaList.count - 1) {
if ([self.delegate respondsToSelector:@selector(presentingViewControllerShouldBeClosed:)])
[self.delegate presentingViewControllerShouldBeClosed:self];
[self destroyCurrentViewController];
[self stopPlayback];
return;
}
......@@ -729,6 +727,12 @@
}
}
- (void)destroyCurrentViewController
{
if ([self.delegate respondsToSelector:@selector(presentingViewControllerShouldBeClosed:)])
[self.delegate presentingViewControllerShouldBeClosed:self];
}
- (void)_updateDisplayedMetadata
{
_needsMetadataUpdate = NO;
......@@ -799,7 +803,7 @@
title = [[_mediaPlayer.media url] lastPathComponent];
} else if (_mediaWasJustStarted) {
_mediaWasJustStarted = NO;
[(VLCAppDelegate *)[UIApplication sharedApplication].delegate presentMovieViewController];
[(VLCAppDelegate *)[UIApplication sharedApplication].delegate presentMovieViewControllerAnimated:YES];
if (item) {
if (_mediaPlayer.numberOfAudioTracks > 2) {
......
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