Skip to content

Commit

Permalink
Merge branch 'release/5.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Sep 19, 2020
2 parents 1db486e + 7f44cad commit e22601f
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Common.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Version information
MARKETING_VERSION = 5.0.2
MARKETING_VERSION = 5.0.3

// Deployment targets
IPHONEOS_DEPLOYMENT_TARGET = 9.0
Expand Down
71 changes: 71 additions & 0 deletions Framework/Sources/Helpers/SRGPictureInPictureFix.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

@import AVKit;
@import UIKit;

@interface SRGDummyPlayerViewController : AVPlayerViewController

@end

@implementation SRGDummyPlayerViewController

- (UIView *)view
{
UIView *view = super.view;
view.hidden = YES;
return view;
}

@end

@interface SRGPictureInPictureFix : NSObject

@end

@implementation SRGPictureInPictureFix

- (instancetype)init
{
if (self = [super init]) {
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
return self;
}

- (void)applicationDidBecomeActive:(NSNotification *)notification
{
static dispatch_once_t s_onceToken;
dispatch_once(&s_onceToken, ^{
// iOS 14 regression: Using `AVPictureInPictureController` leaks an `AVPlayer`instance even afer the
// app released all strong references (reported as FB8561088).
// Somehow Apple manages to circumvent this issue internally with `AVPlayerViewController` which, if
// displayed once, ensures proper behavior afterwards.
SRGDummyPlayerViewController *playerViewController = [[SRGDummyPlayerViewController alloc] init];
playerViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
playerViewController.definesPresentationContext = NO;
playerViewController.player = [AVPlayer new];

UIViewController *rootViewController = UIApplication.sharedApplication.keyWindow.rootViewController;
[rootViewController presentViewController:playerViewController animated:NO completion:^{
[rootViewController dismissViewControllerAnimated:NO completion:nil];
}];
});
}

@end

static SRGPictureInPictureFix *s_pictureInPictureFix;

__attribute__ ((constructor)) void SRGPictureInPictureFixInit(void)
{
if (@available(iOS 14, tvOS 14, *)) {
s_pictureInPictureFix = [[SRGPictureInPictureFix alloc] init];
}
}
4 changes: 4 additions & 0 deletions SRGMediaPlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
6F9643D421307920003C6612 /* SRGAirPlayView~ios.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F9643D02130791F003C6612 /* SRGAirPlayView~ios.m */; };
6F9643D521307920003C6612 /* SRGAirPlayButton~ios.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F9643D121307920003C6612 /* SRGAirPlayButton~ios.m */; };
6F97C7981E7A89C5001AD9B3 /* ModalTransition~ios.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F97C7971E7A89C5001AD9B3 /* ModalTransition~ios.m */; };
6F9A566C2514D29100F30CC6 /* SRGPictureInPictureFix.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F9A566A2514D29100F30CC6 /* SRGPictureInPictureFix.m */; };
6FA98E15211D68AF00969089 /* ConstantsTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FA98E14211D68AE00969089 /* ConstantsTestCase.m */; };
6FBA837B22C4909300AFAF8B /* SRGRouteDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FBA837922C4909300AFAF8B /* SRGRouteDetector.h */; };
6FBA837C22C4909300AFAF8B /* SRGRouteDetector~ios.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FBA837A22C4909300AFAF8B /* SRGRouteDetector~ios.m */; };
Expand Down Expand Up @@ -302,6 +303,7 @@
6F9643D121307920003C6612 /* SRGAirPlayButton~ios.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SRGAirPlayButton~ios.m"; sourceTree = "<group>"; };
6F97C7961E7A89C5001AD9B3 /* ModalTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModalTransition.h; sourceTree = "<group>"; };
6F97C7971E7A89C5001AD9B3 /* ModalTransition~ios.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ModalTransition~ios.m"; sourceTree = "<group>"; };
6F9A566A2514D29100F30CC6 /* SRGPictureInPictureFix.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SRGPictureInPictureFix.m; sourceTree = "<group>"; };
6FA09D791D9E9C1500EDCA64 /* SRGLogger.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SRGLogger.framework; path = Carthage/Build/iOS/SRGLogger.framework; sourceTree = "<group>"; };
6FA1D6081F42C13E00C85D15 /* TestMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestMacros.h; sourceTree = "<group>"; };
6FA98E14211D68AE00969089 /* ConstantsTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConstantsTestCase.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -529,6 +531,7 @@
6F5CA4251FD91A1D00CF175F /* SRGMotionManager~ios.m */,
6F5CA42E1FD91A1D00CF175F /* SRGPeriodicTimeObserver.h */,
6F5CA4271FD91A1D00CF175F /* SRGPeriodicTimeObserver.m */,
6F9A566A2514D29100F30CC6 /* SRGPictureInPictureFix.m */,
6F859F38230A937900ECE021 /* SRGPlayer.h */,
6F859F39230A937900ECE021 /* SRGPlayer.m */,
6F2556D0212FBF63004C8F9A /* SRGPosition.h */,
Expand Down Expand Up @@ -1175,6 +1178,7 @@
6FD71B5E246A767D00AB08FF /* SRGTimePosition.m in Sources */,
6F5CA41A1FD919CD00CF175F /* SRGMediaPlayerView.m in Sources */,
6FCA169F23E829440015B23E /* SRGMediaAccessibility.m in Sources */,
6F9A566C2514D29100F30CC6 /* SRGPictureInPictureFix.m in Sources */,
6FC1C74E22BCD29D00D55625 /* NSTimer+SRGMediaPlayer.m in Sources */,
E6C9860F1D6F458900C45C7A /* SRGTimeSlider~ios.m in Sources */,
6F5CA3F71FD919CD00CF175F /* MAKVONotificationCenter+SRGMediaPlayer.m in Sources */,
Expand Down

0 comments on commit e22601f

Please sign in to comment.