Skip to content

Commit

Permalink
Merge branch 'release/7.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
pyby committed May 20, 2022
2 parents 44836cc + 95f56ad commit b0a28e8
Show file tree
Hide file tree
Showing 19 changed files with 336 additions and 97 deletions.
2 changes: 1 addition & 1 deletion Demo/Demo.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Version information
MARKETING_VERSION = 7.0.0
MARKETING_VERSION = 7.0.1

// Deployment targets
IPHONEOS_DEPLOYMENT_TARGET = 9.0
Expand Down
12 changes: 9 additions & 3 deletions Demo/Sources/Helpers/ModalTransition~ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ - (void)setupTransition:(id<UIViewControllerContextTransitioning>)transitionCont

UIView *containerView = [transitionContext containerView];

UIView *dimmingView = [[UIView alloc] initWithFrame:containerView.bounds];
dimmingView.frame = containerView.bounds;
dimmingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
UIView *dimmingView = [[UIView alloc] init];
dimmingView.backgroundColor = [UIColor colorWithWhite:0.f alpha:0.5f];
self.dimmingView = dimmingView;

Expand All @@ -73,6 +71,14 @@ - (void)setupTransition:(id<UIViewControllerContextTransitioning>)transitionCont
[containerView insertSubview:dimmingView belowSubview:fromView];
}

dimmingView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[dimmingView.topAnchor constraintEqualToAnchor:containerView.topAnchor],
[dimmingView.bottomAnchor constraintEqualToAnchor:containerView.bottomAnchor],
[dimmingView.leadingAnchor constraintEqualToAnchor:containerView.leadingAnchor],
[dimmingView.trailingAnchor constraintEqualToAnchor:containerView.trailingAnchor]
]];

[self updateTransition:transitionContext withProgress:0.f];
}

Expand Down
13 changes: 10 additions & 3 deletions Demo/Sources/Players/Inline/InlinePlayerViewController~ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@ - (void)viewDidLoad

- (void)attachPlayerView
{
self.mediaPlayerController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mediaPlayerController.view.frame = self.playerHostView.bounds;
[self.playerHostView insertSubview:self.mediaPlayerController.view atIndex:0];
UIView *playerView = self.mediaPlayerController.view;
[self.playerHostView insertSubview:playerView atIndex:0];

playerView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[playerView.topAnchor constraintEqualToAnchor:self.playerHostView.topAnchor],
[playerView.bottomAnchor constraintEqualToAnchor:self.playerHostView.bottomAnchor],
[playerView.leadingAnchor constraintEqualToAnchor:self.playerHostView.leadingAnchor],
[playerView.trailingAnchor constraintEqualToAnchor:self.playerHostView.trailingAnchor]
]];
}

- (void)detachPlayerView
Expand Down
10 changes: 8 additions & 2 deletions Demo/Sources/Players/Multi/MultiPlayerViewController~ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,15 @@ - (void)displayMediaPlayerControllers:(NSArray<SRGMediaPlayerController *> *)med
self.airPlayButton.mediaPlayerController = mediaPlayerController;

UIView *playerView = mediaPlayerController.view;
playerView.frame = self.mainPlayerView.bounds;
playerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.mainPlayerView addSubview:playerView];

playerView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[playerView.topAnchor constraintEqualToAnchor:self.mainPlayerView.topAnchor],
[playerView.bottomAnchor constraintEqualToAnchor:self.mainPlayerView.bottomAnchor],
[playerView.leadingAnchor constraintEqualToAnchor:self.mainPlayerView.leadingAnchor],
[playerView.trailingAnchor constraintEqualToAnchor:self.mainPlayerView.trailingAnchor]
]];
}
else {
mediaPlayerController.playerConfigurationBlock = ^(AVPlayer * _Nonnull player) {
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import PackageDescription

struct ProjectSettings {
static let marketingVersion: String = "7.0.0"
static let marketingVersion: String = "7.0.1"
}

let package = Package(
Expand Down
10 changes: 8 additions & 2 deletions Sources/SRGMediaPlayer/SRGAirPlayButton~ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ - (void)prepareForInterfaceBuilder
// Use a fake button for Interface Builder rendering, since the volume view (and thus its AirPlay button) is only
// visible on a device
UIButton *fakeInterfaceBuilderButton = [UIButton buttonWithType:UIButtonTypeSystem];
fakeInterfaceBuilderButton.frame = self.bounds;
fakeInterfaceBuilderButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
fakeInterfaceBuilderButton.imageView.contentMode = UIViewContentModeScaleAspectFill;

UIImage *image = [UIImage imageNamed:@"airplay_audio" inBundle:SWIFTPM_MODULE_BUNDLE compatibleWithTraitCollection:nil];
Expand All @@ -322,6 +320,14 @@ - (void)prepareForInterfaceBuilder
[self addSubview:fakeInterfaceBuilderButton];
self.fakeInterfaceBuilderButton = fakeInterfaceBuilderButton;

fakeInterfaceBuilderButton.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[fakeInterfaceBuilderButton.topAnchor constraintEqualToAnchor:self.topAnchor],
[fakeInterfaceBuilderButton.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
[fakeInterfaceBuilderButton.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[fakeInterfaceBuilderButton.trailingAnchor constraintEqualToAnchor:self.trailingAnchor]
]];

if (@available(iOS 11, *)) {
self.routePickerView.hidden = YES;
}
Expand Down
11 changes: 9 additions & 2 deletions Sources/SRGMediaPlayer/SRGMediaPlaybackMonoscopicView.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,19 @@ - (void)didSetupScene:(SCNScene *)scene withCameraNode:(SCNNode *)cameraNode

static void commonInit(SRGMediaPlaybackMonoscopicView *self)
{
SCNView *sceneView = [[SCNView alloc] initWithFrame:self.bounds options:nil];
sceneView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
SCNView *sceneView = [[SCNView alloc] init];
sceneView.backgroundColor = UIColor.clearColor;
sceneView.hidden = YES;
sceneView.playing = YES;
sceneView.delegate = self;
[self addSubview:sceneView];
self.sceneView = sceneView;

sceneView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[sceneView.topAnchor constraintEqualToAnchor:self.topAnchor],
[sceneView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
[sceneView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[sceneView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor]
]];
}
14 changes: 7 additions & 7 deletions Sources/SRGMediaPlayer/SRGMediaPlayerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -660,20 +660,20 @@ - (SRGMediaPlayerStreamType)streamTypeForPlayerItem:(AVPlayerItem *)playerItem t

/**
* Calculate the effective playback rate. This is required for DVR streams which require the rate to be adjusted near
* the live edge to avoid playback issues (playing in the future is not possible). This method also delivers correct
* effective playback rates for on-demand and livestreams without DVR.
* the live edge to avoid playback issues (playing in the future is not possible) as chunks are added near the live
* edge. This method also delivers correct effective playback rates for on-demand and livestreams without DVR.
*
* For a DVR livestreams this method adjusts the playback rate differently depending on where the playhead position
* currently is, as follows:
*
*
* Restore to desired rate Force to 1
* Restore to desired rate Limit to 1 at most
*
* ◀────────────────── ──────────────────▶
*
* ┌─────────────────────────────────────┬────────────────────────────────────────────────────┬───────────────────────────────┐
* │ │ │ │
* │ Desired effective rate │ Keep current rate │ Effective rate = 1 │
* │ Desired rate │ Keep current rate │ Max rate = 1
* │ │ │ │
* └─────────────────────────────────────┼────────────────────────────────────────────────────┼───────────────────────────────┤
* │ │ │
Expand Down Expand Up @@ -702,10 +702,10 @@ - (float)effectivePlaybackRateForPlayerItem:(AVPlayerItem *)playerItem timeRange
else if (! [self isNearLiveEdgeForPlayerItem:playerItem tolerance:kLiveEdgeTolerance + self.liveTolerance timeRange:timeRange streamType:streamType]) {
return self.playbackRate;
}
// In between both tolerances we just keep the current effective playback rate. This ensures the optimal effective
// playback rate is applied, whether we are nearing the edge or getting away from it.
// In between both tolerances, and if fast playback speed is desired, we keep the current effective playback rate. This
// ensures the optimal effective playback rate is applied, whether we are nearing the edge or getting away from it.
else {
return (_effectivePlaybackRate == 1.f) ? _effectivePlaybackRate : self.playbackRate;
return (self.playbackRate > 1.f && _effectivePlaybackRate == 1.f) ? _effectivePlaybackRate : self.playbackRate;
}
}

Expand Down
11 changes: 9 additions & 2 deletions Sources/SRGMediaPlayer/SRGMediaPlayerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,17 @@ - (void)updateSubviewsWithPlayer:(AVPlayer *)player
[self.playbackView setPlayer:nil withAssetDimensions:CGSizeZero];
[self.playbackView removeFromSuperview];

UIView<SRGMediaPlaybackView> *playbackView = [[playbackViewClass alloc] initWithFrame:self.bounds];
playbackView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
UIView<SRGMediaPlaybackView> *playbackView = [[playbackViewClass alloc] init];
[self addSubview:playbackView];
self.playbackView = playbackView;

playbackView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[playbackView.topAnchor constraintEqualToAnchor:self.topAnchor],
[playbackView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
[playbackView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[playbackView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor]
]];
}

if (self.playbackView.player != player) {
Expand Down
20 changes: 16 additions & 4 deletions Sources/SRGMediaPlayer/SRGPictureInPictureButton~ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ - (void)prepareForInterfaceBuilder
// intrinsic size is namely incorrect, leading to layout issues. It seems that using a button added in
// -prepareForInterfaceBuilder works, though
UIButton *fakeInterfaceBuilderButton = [UIButton buttonWithType:UIButtonTypeSystem];
fakeInterfaceBuilderButton.frame = self.bounds;
fakeInterfaceBuilderButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
fakeInterfaceBuilderButton.imageView.contentMode = UIViewContentModeScaleAspectFill;

UIImage *image = [UIImage imageNamed:@"picture_in_picture_start" inBundle:SWIFTPM_MODULE_BUNDLE compatibleWithTraitCollection:nil];
Expand All @@ -210,6 +208,14 @@ - (void)prepareForInterfaceBuilder
[self addSubview:fakeInterfaceBuilderButton];
self.fakeInterfaceBuilderButton = fakeInterfaceBuilderButton;

fakeInterfaceBuilderButton.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[fakeInterfaceBuilderButton.topAnchor constraintEqualToAnchor:self.topAnchor],
[fakeInterfaceBuilderButton.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
[fakeInterfaceBuilderButton.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[fakeInterfaceBuilderButton.trailingAnchor constraintEqualToAnchor:self.trailingAnchor]
]];

// Hide the normal button
self.button.hidden = YES;
}
Expand Down Expand Up @@ -250,13 +256,19 @@ - (NSArray *)accessibilityElements
static void commonInit(SRGPictureInPictureButton *self)
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = self.bounds;
button.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
button.imageView.contentMode = UIViewContentModeScaleAspectFill;
[button addTarget:self action:@selector(srg_pictureInPictureButton_togglePictureInPicture:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:button];
self.button = button;

button.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[button.topAnchor constraintEqualToAnchor:self.topAnchor],
[button.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
[button.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[button.trailingAnchor constraintEqualToAnchor:self.trailingAnchor]
]];

self.hidden = YES;
}

Expand Down
20 changes: 16 additions & 4 deletions Sources/SRGMediaPlayer/SRGPlaybackSettingsButton~ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ - (void)prepareForInterfaceBuilder
// intrinsic size is namely incorrect, leading to layout issues. It seems that using a button added in
// -prepareForInterfaceBuilder works, though
UIButton *fakeInterfaceBuilderButton = [UIButton buttonWithType:UIButtonTypeSystem];
fakeInterfaceBuilderButton.frame = self.bounds;
fakeInterfaceBuilderButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
fakeInterfaceBuilderButton.imageView.contentMode = UIViewContentModeScaleAspectFill;

UIImage *image = [UIImage imageNamed:@"more" inBundle:SWIFTPM_MODULE_BUNDLE compatibleWithTraitCollection:nil];
Expand All @@ -254,6 +252,14 @@ - (void)prepareForInterfaceBuilder
[self addSubview:fakeInterfaceBuilderButton];
self.fakeInterfaceBuilderButton = fakeInterfaceBuilderButton;

fakeInterfaceBuilderButton.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[fakeInterfaceBuilderButton.topAnchor constraintEqualToAnchor:self.topAnchor],
[fakeInterfaceBuilderButton.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
[fakeInterfaceBuilderButton.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[fakeInterfaceBuilderButton.trailingAnchor constraintEqualToAnchor:self.trailingAnchor]
]];

// Hide the normal button
self.button.hidden = YES;
}
Expand Down Expand Up @@ -294,13 +300,19 @@ - (void)subtitleTrackDidChange:(NSNotification *)notification
static void commonInit(SRGPlaybackSettingsButton *self)
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = self.bounds;
button.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
button.imageView.contentMode = UIViewContentModeScaleAspectFill;
[button addTarget:self action:@selector(showTracks:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:button];
self.button = button;

button.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[button.topAnchor constraintEqualToAnchor:self.topAnchor],
[button.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
[button.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[button.trailingAnchor constraintEqualToAnchor:self.trailingAnchor]
]];

self.hidden = YES;
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/SRGMediaPlayer/SRGPlaybackSettingsHeaderView~ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,24 @@ - (void)setTintColor:(UIColor *)tintColor

static void commonInit(SRGPlaybackSettingsHeaderView *self)
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
imageView.translatesAutoresizingMaskIntoConstraints = NO;
UIImageView *imageView = [[UIImageView alloc] init];
[self.contentView addSubview:imageView];
self.imageView = imageView;

imageView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[imageView.leadingAnchor constraintEqualToAnchor:self.contentView.layoutMarginsGuide.leadingAnchor],
[imageView.bottomAnchor constraintEqualToAnchor:self.contentView.bottomAnchor constant:-4.f],
[imageView.widthAnchor constraintEqualToConstant:25.f],
[imageView.heightAnchor constraintEqualToConstant:25.f]
]];

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
[self.contentView addSubview:titleLabel];
self.titleLabel = titleLabel;

titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[titleLabel.leadingAnchor constraintEqualToAnchor:imageView.trailingAnchor constant:6.f],
[titleLabel.trailingAnchor constraintEqualToAnchor:self.contentView.layoutMarginsGuide.trailingAnchor],
Expand Down
4 changes: 2 additions & 2 deletions Sources/SRGMediaPlayer/SRGPlaybackSettingsSegmentCell~ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ @implementation SRGPlaybackSettingsSegmentCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithFrame:self.contentView.bounds];
segmentedControl.translatesAutoresizingMaskIntoConstraints = NO;
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] init];
[segmentedControl addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
[self.contentView addSubview:segmentedControl];
self.segmentedControl = segmentedControl;

segmentedControl.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[segmentedControl.leadingAnchor constraintEqualToAnchor:self.contentView.layoutMarginsGuide.leadingAnchor],
[segmentedControl.trailingAnchor constraintEqualToAnchor:self.contentView.layoutMarginsGuide.trailingAnchor],
Expand Down
11 changes: 9 additions & 2 deletions Sources/SRGMediaPlayer/SRGPlaybackSettingsViewController~ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,18 @@ - (void)loadView
{
UIView *view = [[UIView alloc] initWithFrame:UIScreen.mainScreen.bounds];

UITableView *tableView = [[UITableView alloc] initWithFrame:view.bounds style:UITableViewStyleGrouped];
tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
[view addSubview:tableView];
self.tableView = tableView;

tableView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[tableView.topAnchor constraintEqualToAnchor:view.topAnchor],
[tableView.bottomAnchor constraintEqualToAnchor:view.bottomAnchor],
[tableView.leadingAnchor constraintEqualToAnchor:view.leadingAnchor],
[tableView.trailingAnchor constraintEqualToAnchor:view.trailingAnchor]
]];

self.view = view;
}

Expand Down
Loading

0 comments on commit b0a28e8

Please sign in to comment.