Skip to content

Commit

Permalink
Merge branch 'hotfix/1.9.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
pyby committed Dec 15, 2016
2 parents 686ffa6 + f1e8833 commit 3ddb186
Show file tree
Hide file tree
Showing 22 changed files with 7,583 additions and 2,196 deletions.
16 changes: 8 additions & 8 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ PODS:
- libextobjc/RuntimeExtensions
- libextobjc/RuntimeExtensions (0.4.1)
- MAKVONotificationCenter (0.0.2)
- SDWebImage (3.8.1):
- SDWebImage/Core (= 3.8.1)
- SDWebImage/Core (3.8.1)
- SRGMediaPlayer (1.9.11):
- SDWebImage (3.8.2):
- SDWebImage/Core (= 3.8.2)
- SDWebImage/Core (3.8.2)
- SRGMediaPlayer (1.9.12):
- libextobjc/EXTScope (~> 0.4.1)
- SRGMediaPlayer/Version (= 1.9.11)
- SRGMediaPlayer/Version (= 1.9.12)
- TransitionKit (~> 2.2.0)
- SRGMediaPlayer/Version (1.9.11):
- SRGMediaPlayer/Version (1.9.12):
- libextobjc/EXTScope (~> 0.4.1)
- TransitionKit (~> 2.2.0)
- TransitionKit (2.2.1)
Expand All @@ -39,8 +39,8 @@ SPEC CHECKSUMS:
CocoaLumberjack: 97fab7ee5f507fe54445cca7ea80f926729cfd15
libextobjc: a650fc1bf489a3d3a9bc2e621efa3e1006fc5471
MAKVONotificationCenter: eddfb85e77040323ee43a0fddbe616926ec005a8
SDWebImage: 35f9627a3e44b4f292a8a8ce6a531fa488239b91
SRGMediaPlayer: 70642b1f7a77622bac6cd126773119fb44c94d73
SDWebImage: 098e97e6176540799c27e804c96653ee0833d13c
SRGMediaPlayer: 46a3e37260dc5d26731993e8ed55354aea46efa5
TransitionKit: 9ceccda4cd0cdc0a05ef85eb235e5a3292c3c250

PODFILE CHECKSUM: 87d8e61331e5c99b52d279095b184aa2eb9ae51c
Expand Down
6 changes: 3 additions & 3 deletions Pods/Local Podspecs/SRGMediaPlayer.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9,338 changes: 7,176 additions & 2,162 deletions Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions RTSMediaPlayer/NSBundle+RTSMediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Return a localized string from the media player resource bundle
*/
#define RTSMediaPlayerLocalizedString(key, comment) [[NSBundle RTSMediaPlayerBundle] localizedStringForKey:(key) value:@"" table:nil]
#define SRGMediaPlayerAccessibityLocalizedString(key, comment) [[NSBundle RTSMediaPlayerBundle] localizedStringForKey:(key) value:@"" table:@"Accessibility"]

@interface NSBundle (RTSMediaPlayer)

Expand Down
24 changes: 24 additions & 0 deletions RTSMediaPlayer/RTSMediaPlayerConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* ---------------
*/

FOUNDATION_EXTERN NSTimeInterval const RTSMediaPlayerOverlayHidingDefaultDelay; // 5 seconds.
FOUNDATION_EXTERN NSTimeInterval const RTSMediaLiveDefaultTolerance; // in seconds.

/**
Expand Down Expand Up @@ -200,3 +201,26 @@ FOUNDATION_EXTERN NSString * const RTSMediaPlaybackSegmentChangeValueInfoKey;
* The key to access an `NSNumber` (wrapping a boolean) indicating whether the change is requested by the user or not.
*/
FOUNDATION_EXTERN NSString * const RTSMediaPlaybackSegmentChangeUserSelectInfoKey;

/**
* ---------------------------
* @name Accessibility strings
* ---------------------------
*
* You can use those string, or the macro SRGMediaPlayerAccessibityLocalizedString(key, nil) to get other strings
*/

/**
* A translated accessibility label, could be use for a Go to Live button.
*/
FOUNDATION_EXTERN NSString * RTSMediaPlaybackButtonGoToLiveAccessibilityLabel;

/**
* A translated accessibility label, could be use for backward button, Use it as a pre-formatted string: "%@ backward", time.
*/
FOUNDATION_EXTERN NSString * RTSMediaPlaybackButtonBackwardAccessibilityLabelFormat;

/**
* A translated accessibility label, could be use for forward button. Use it as a pre-formatted string: "%@ forward", time.
*/
FOUNDATION_EXTERN NSString * RTSMediaPlaybackButtonForwardAccessibilityLabelFormat;
4 changes: 2 additions & 2 deletions RTSMediaPlayer/RTSMediaPlayerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
@property (copy) IBOutletCollection(UIView) NSArray *overlayViews;

/**
* The delay after which the overlay views are hidden. Default to `RTSMediaPlayerOverlayHidingDelay` (5 sec).
* Ignored if <= 0.0;
* The delay after which the overlay views are hidden. Default to `RTSMediaPlayerOverlayHidingDefaultDelay` (5 sec).
* Never hide if == 0.0. Ignored if < 0.0;
*/
@property (assign) NSTimeInterval overlayViewsHidingDelay;

Expand Down
10 changes: 5 additions & 5 deletions RTSMediaPlayer/RTSMediaPlayerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
static const void * const RTSMediaPlayerPictureInPicturePossibleContext = &RTSMediaPlayerPictureInPicturePossibleContext;
static const void * const RTSMediaPlayerPictureInPictureActiveContext = &RTSMediaPlayerPictureInPictureActiveContext;

NSTimeInterval const RTSMediaPlayerOverlayHidingDelay = 5.0;
NSTimeInterval const RTSMediaPlayerOverlayHidingDefaultDelay = 5.0;
NSTimeInterval const RTSMediaLiveDefaultTolerance = 30.0; // same tolerance as built-in iOS player

NSString * const RTSMediaPlayerErrorDomain = @"RTSMediaPlayerErrorDomain";
Expand Down Expand Up @@ -136,7 +136,7 @@ - (instancetype)initWithContentIdentifier:(NSString *)identifier dataSource:(id<
_allowsExternalPlayback = YES;
_usesExternalPlaybackWhileExternalScreenIsActive = NO;

self.overlayViewsHidingDelay = RTSMediaPlayerOverlayHidingDelay;
self.overlayViewsHidingDelay = RTSMediaPlayerOverlayHidingDefaultDelay;
self.periodicTimeObservers = [NSMutableDictionary dictionary];

[self.stateMachine activate];
Expand Down Expand Up @@ -797,7 +797,7 @@ - (void)registerPlaybackRatePeriodicTimeObserver
return;
}

if ((self.player.rate == 1) && [self.stateMachine.currentState isEqual:self.pausedState]) {
if ((self.player.rate == 1) && ([self.stateMachine.currentState isEqual:self.pausedState] || [self.stateMachine.currentState isEqual:self.stalledState])) {
[self fireEvent:self.playEvent userInfo:nil];
}

Expand Down Expand Up @@ -1190,7 +1190,7 @@ - (dispatch_source_t)idleTimer
@weakify(self)
dispatch_source_set_event_handler(_idleTimer, ^{
@strongify(self)
if ([self.stateMachine.currentState isEqual:self.playingState])
if ([self.stateMachine.currentState isEqual:self.playingState] && self.overlayViewsHidingDelay != 0.0)
[self setOverlaysVisible:NO];
});
dispatch_resume(_idleTimer);
Expand All @@ -1200,7 +1200,7 @@ - (dispatch_source_t)idleTimer

- (void)resetIdleTimer
{
int64_t delayInNanoseconds = ((self.overlayViewsHidingDelay > 0.0) ? self.overlayViewsHidingDelay : RTSMediaPlayerOverlayHidingDelay) * NSEC_PER_SEC;
int64_t delayInNanoseconds = ((self.overlayViewsHidingDelay > 0.0) ? self.overlayViewsHidingDelay : RTSMediaPlayerOverlayHidingDefaultDelay) * NSEC_PER_SEC;
int64_t toleranceInNanoseconds = 0.1 * NSEC_PER_SEC;
dispatch_source_set_timer(self.idleTimer, dispatch_time(DISPATCH_TIME_NOW, delayInNanoseconds), DISPATCH_TIME_FOREVER, toleranceInNanoseconds);
}
Expand Down
15 changes: 15 additions & 0 deletions RTSMediaPlayer/RTSMediaPlayerPlaybackButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,21 @@

#import "RTSMediaPlayerController.h"
#import "RTSMediaPlayerIconTemplate.h"
#import "NSBundle+RTSMediaPlayer.h"

NSString * RTSMediaPlaybackButtonGoToLiveAccessibilityLabel = nil;
NSString * RTSMediaPlaybackButtonBackwardAccessibilityLabelFormat = nil;
NSString * RTSMediaPlaybackButtonForwardAccessibilityLabelFormat = nil;

@implementation RTSMediaPlayerPlaybackButton

- (void)initialize
{
RTSMediaPlaybackButtonGoToLiveAccessibilityLabel = SRGMediaPlayerAccessibityLocalizedString(@"Go to live", @"A go to live button");
RTSMediaPlaybackButtonBackwardAccessibilityLabelFormat = SRGMediaPlayerAccessibityLocalizedString(@"%@ backward", @"A seek backward button");
RTSMediaPlaybackButtonForwardAccessibilityLabelFormat = SRGMediaPlayerAccessibityLocalizedString(@"%@ forward", @"A seek forward button");
}

- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
Expand Down Expand Up @@ -77,15 +89,18 @@ - (void)refreshButton
if ([self hasStopButton]) {
normalImage = self.stopImage ?: [RTSMediaPlayerIconTemplate stopImageWithSize:self.bounds.size color:self.normalColor];
highlightedImage = self.stopImage ?: [RTSMediaPlayerIconTemplate stopImageWithSize:self.bounds.size color:self.hightlightColor];
self.accessibilityLabel = SRGMediaPlayerAccessibityLocalizedString(@"Stop", @"Stop state of the Play/Pause/Stop button");
}
else {
normalImage = self.pauseImage ?: [RTSMediaPlayerIconTemplate pauseImageWithSize:self.bounds.size color:self.normalColor];
highlightedImage = self.pauseImage ?: [RTSMediaPlayerIconTemplate pauseImageWithSize:self.bounds.size color:self.hightlightColor];
self.accessibilityLabel = SRGMediaPlayerAccessibityLocalizedString(@"Pause", @"Pause state of the Play/Pause/Stop button");
}
}
else {
normalImage = self.playImage ?: [RTSMediaPlayerIconTemplate playImageWithSize:self.bounds.size color:self.normalColor];
highlightedImage = self.playImage ?: [RTSMediaPlayerIconTemplate playImageWithSize:self.bounds.size color:self.hightlightColor];
self.accessibilityLabel = SRGMediaPlayerAccessibityLocalizedString(@"Play", @"Play state of the Play/Pause/Stop button");
}
[self setImage:normalImage forState:UIControlStateNormal];
[self setImage:highlightedImage forState:UIControlStateHighlighted];
Expand Down
7 changes: 7 additions & 0 deletions RTSMediaPlayer/RTSPictureInPictureButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ - (void)updateAppearanceForMediaPlayerController:(RTSMediaPlayerController *)med

UIImage *image = pictureInPictureController.pictureInPictureActive ? RTSPictureInPictureButtonStopImage() : RTSPictureInPictureButtonStartImage();
[self setImage:image forState:UIControlStateNormal];
if (pictureInPictureController.pictureInPictureActive) {
self.accessibilityLabel = SRGMediaPlayerAccessibityLocalizedString(@"Stop Picture in Picture", @"Picture In Picture button state, when PiP is active");
}
else {
self.accessibilityLabel = SRGMediaPlayerAccessibityLocalizedString(@"Switch to Picture in Picture", @"Picture In Picture button state, when PiP is available");
}
}

#pragma mark Actions
Expand Down Expand Up @@ -110,6 +116,7 @@ - (void)pictureInPictureStateDidChange:(NSNotification *)notification
static void commonInit(RTSPictureInPictureButton *self)
{
[self addTarget:self action:@selector(togglePictureInPicture:) forControlEvents:UIControlEventTouchUpInside];
self.accessibilityLabel = SRGMediaPlayerAccessibityLocalizedString(@"Switch to Picture in Picture", @"Picture In Picture button state, when PiP is available");
}

#pragma mark Functions
Expand Down
48 changes: 48 additions & 0 deletions RTSMediaPlayer/RTSTimeSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@
return [NSString stringWithFormat:@"%@%02d:%02d", negative ? @"-" : @"", minute, second];
}

static NSString *RTSTimeSliderAccessibilityFormatter(NSTimeInterval seconds)
{
if (isnan(seconds))
return SRGMediaPlayerAccessibityLocalizedString(@"No duration", @"Time state if no duration");
else if (isinf(seconds))
return SRGMediaPlayerAccessibityLocalizedString(@"Infinity duration", @"Time state if infinity duration");

static dispatch_once_t onceToken;
static NSDateComponentsFormatter *dateComponentsFormatter;
dispatch_once(&onceToken, ^{
dateComponentsFormatter = [[NSDateComponentsFormatter alloc] init];
dateComponentsFormatter.unitsStyle = NSDateComponentsFormatterUnitsStyleFull;
dateComponentsFormatter.allowedUnits = NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
});

return [dateComponentsFormatter stringFromTimeInterval:ABS(seconds)];
}

@interface RTSTimeSlider ()

@property (weak) id periodicTimeObserver;
Expand Down Expand Up @@ -171,11 +189,15 @@ - (void) updateTimeRangeLabels
if (self.live)
{
self.valueLabel.text = @"--:--";
self.valueLabel.accessibilityLabel = nil;
self.timeLeftValueLabel.text = RTSMediaPlayerLocalizedString(@"Live", nil);
self.timeLeftValueLabel.accessibilityLabel = nil;
}
else {
self.valueLabel.text = RTSTimeSliderFormatter(self.value);
self.valueLabel.accessibilityLabel = [NSString stringWithFormat:SRGMediaPlayerAccessibityLocalizedString(@"%@ played", @"Label on slider for time played"), RTSTimeSliderAccessibilityFormatter(self.value)];
self.timeLeftValueLabel.text = RTSTimeSliderFormatter(self.value - self.maximumValue);
self.timeLeftValueLabel.accessibilityLabel = [NSString stringWithFormat:SRGMediaPlayerAccessibityLocalizedString(@"%@ remaining", @"Label on slider for time remaining"), RTSTimeSliderAccessibilityFormatter(self.value - self.maximumValue)];
}
}

Expand Down Expand Up @@ -418,6 +440,32 @@ - (void)willMoveToWindow:(UIWindow *)window
}
}

- (NSString *)accessibilityLabel
{
AVPlayerItem *playerItem = self.mediaPlayerController.playerItem;
if (! playerItem || self.mediaPlayerController.playbackState == RTSMediaPlaybackStateIdle || self.mediaPlayerController.playbackState == RTSMediaPlaybackStateEnded
|| playerItem.status != AVPlayerItemStatusReadyToPlay) {
return SRGMediaPlayerAccessibityLocalizedString(@"Nothing playing", @"Slider state when nothing to play");;
}
else if (self.live)
{
return SRGMediaPlayerAccessibityLocalizedString(@"Playing in live", @"Slider state when playing live");
}
else if (self.mediaPlayerController.streamType == RTSMediaStreamTypeDVR) {
return [NSString stringWithFormat:SRGMediaPlayerAccessibityLocalizedString(@"%@ late to direct", @"Slider state when playing DVR"),
RTSTimeSliderAccessibilityFormatter(self.maximumValue - self.value)];
}
else {
CGFloat ratio = self.value / self.maximumValue;
return [NSString stringWithFormat:SRGMediaPlayerAccessibityLocalizedString(@"%.0f%% played", @"Slider state when playing AOD/VOD, in percentage"), round(ratio * 100) ];
}
}

- (NSString *)accessibilityValue
{
return nil;
}

#pragma mark Notifications

- (void)timesliderPlaybackStateDidChange:(NSNotification *)notification
Expand Down
5 changes: 5 additions & 0 deletions RTSMediaPlayer/RTSVolumeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#import "RTSVolumeView.h"
#import <MediaPlayer/MediaPlayer.h>

#import "NSBundle+RTSMediaPlayer.h"

@interface RTSVolumeView ()
@property MPVolumeView *mpVolumeView;
@end
Expand All @@ -15,10 +17,13 @@ @implementation RTSVolumeView

- (void) awakeFromNib
{
[super awakeFromNib];

self.mpVolumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))];
self.mpVolumeView.showsRouteButton = NO;
self.mpVolumeView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:self.mpVolumeView];
self.accessibilityLabel = SRGMediaPlayerAccessibityLocalizedString(@"AirPlay", @"AirPlay button");
}

- (void) setHidden:(BOOL)hidden
Expand Down
Loading

0 comments on commit 3ddb186

Please sign in to comment.