Skip to content

Commit

Permalink
Merge branch 'release/1.8.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed May 26, 2016
2 parents 701b19b + 0464385 commit d6ecc22
Show file tree
Hide file tree
Showing 15 changed files with 207 additions and 43 deletions.
8 changes: 4 additions & 4 deletions Podfile.lock
Expand Up @@ -14,11 +14,11 @@ PODS:
- SDWebImage (3.7.0):
- SDWebImage/Core (= 3.7.0)
- SDWebImage/Core (3.7.0)
- SRGMediaPlayer (1.8.10):
- SRGMediaPlayer (1.8.11):
- libextobjc/EXTScope (~> 0.4.1)
- SRGMediaPlayer/Version (= 1.8.10)
- SRGMediaPlayer/Version (= 1.8.11)
- TransitionKit (~> 2.2.0)
- SRGMediaPlayer/Version (1.8.10):
- SRGMediaPlayer/Version (1.8.11):
- libextobjc/EXTScope (~> 0.4.1)
- TransitionKit (~> 2.2.0)
- TransitionKit (2.2.0)
Expand All @@ -40,7 +40,7 @@ SPEC CHECKSUMS:
libextobjc: a650fc1bf489a3d3a9bc2e621efa3e1006fc5471
MAKVONotificationCenter: eddfb85e77040323ee43a0fddbe616926ec005a8
SDWebImage: b42db92951f9d565c55f1d7f1d5efe47e33a7515
SRGMediaPlayer: 470cb3546c2985587d501dd2c9823fcc03ade885
SRGMediaPlayer: 07f58274d8ebae1450f7e2155f34b68ec6933ccd
TransitionKit: 5c9001a77acc409d71f26a4eba0159cf8619c418

COCOAPODS: 0.39.0
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.

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

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

26 changes: 13 additions & 13 deletions Pods/Pods.xcodeproj/project.pbxproj

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.

16 changes: 15 additions & 1 deletion RTSMediaPlayer/RTSMediaPlayerController.h
Expand Up @@ -203,10 +203,16 @@
- (void)seekToTime:(CMTime)time completionHandler:(void (^)(BOOL finished))completionHandler;

/**
* Play the current media, starting at a specific time
* Play the current media, starting at a specific time (the player seeks if it was already playing)
*/
- (void)playAtTime:(CMTime)time;

/**
* Play the current media, starting at a specific time, and calling the completion handler when playback resumes
* at the specified time (the player seeks if it was already playing)
*/
- (void)playAtTime:(CMTime)time completionHandler:(void (^)(BOOL finished))completionHandler;

/**
* Start playing a media specified using its identifier, starting at a specific time. Retrieving the media URL requires
* a data source to be bound to the player controller
Expand Down Expand Up @@ -248,6 +254,14 @@
*/
@property (nonatomic, readonly, getter=isLive) BOOL live;

/**
* The minimum window length which must be available for a stream to be considered to be a DVR stream, in seconds. The
* default value is 0. This setting can be used so that streams detected as DVR ones because their window is small can
* behave as live streams. This is useful to avoid usual related seeking issues, or slider hiccups during playback, most
* notably
*/
@property (nonatomic) NSTimeInterval minimumDVRWindowLength;

/**
* Return the tolerance (in seconds) for a DVR stream to be considered being played in live conditions. If the stream
* playhead is located within the last liveTolerance conditions of the stream, it is considered to be live, not live
Expand Down
34 changes: 30 additions & 4 deletions RTSMediaPlayer/RTSMediaPlayerController.m
Expand Up @@ -520,12 +520,17 @@ - (void)seekToTime:(CMTime)time completionHandler:(void (^)(BOOL finished))compl
}

- (void)playAtTime:(CMTime)time
{
[self playAtTime:time completionHandler:nil];
}

- (void)playAtTime:(CMTime)time completionHandler:(void (^)(BOOL finished))completionHandler;
{
if ([self.stateMachine.currentState isEqual:self.idleState]) {
[self loadPlayerAndAutoStartAtTime:[NSValue valueWithCMTime:time]];
}
else {
[self seekToTime:time completionHandler:nil];
[self seekToTime:time completionHandler:completionHandler];
}
}

Expand Down Expand Up @@ -579,7 +584,15 @@ - (CMTimeRange)timeRange
return kCMTimeRangeInvalid;
}

return CMTimeRangeFromTimeToTime(firstSeekableTimeRange.start, CMTimeRangeGetEnd(lastSeekableTimeRange));
CMTimeRange timeRange = CMTimeRangeFromTimeToTime(firstSeekableTimeRange.start, CMTimeRangeGetEnd(lastSeekableTimeRange));

// DVR window size too small. Check that we the stream is not an on-demand one first, of course
if (CMTIME_IS_INDEFINITE(self.playerItem.duration) && CMTimeGetSeconds(timeRange.duration) < self.minimumDVRWindowLength) {
return CMTimeRangeMake(timeRange.start, kCMTimeZero);
}
else {
return timeRange;
}
}

- (RTSMediaType)mediaType
Expand All @@ -599,10 +612,12 @@ - (RTSMediaType)mediaType

- (RTSMediaStreamType)streamType
{
if (CMTIMERANGE_IS_INVALID(self.timeRange)) {
CMTimeRange timeRange = self.timeRange;

if (CMTIMERANGE_IS_INVALID(timeRange)) {
return RTSMediaStreamTypeUnknown;
}
else if (CMTIMERANGE_IS_EMPTY(self.timeRange)) {
else if (CMTIMERANGE_IS_EMPTY(timeRange)) {
return RTSMediaStreamTypeLive;
}
else if (CMTIME_IS_INDEFINITE(self.playerItem.duration)) {
Expand All @@ -613,6 +628,17 @@ - (RTSMediaStreamType)streamType
}
}

- (void)setMinimumDVRWindowLength:(NSTimeInterval)minimumDVRWindowLength
{
if (minimumDVRWindowLength < 0.) {
RTSMediaPlayerLogWarning(@"The minimum DVR window length cannot be negative. Set to 0");
_minimumDVRWindowLength = 0.;
}
else {
_minimumDVRWindowLength = minimumDVRWindowLength;
}
}

- (void)setLiveTolerance:(NSTimeInterval)liveTolerance
{
if (liveTolerance < 0.) {
Expand Down
8 changes: 8 additions & 0 deletions RTSMediaPlayer/RTSMediaPlayerIconTemplate.h
Expand Up @@ -27,4 +27,12 @@
*/
+ (UIImage *) pauseImageWithSize:(CGSize)size color:(UIColor *)color;

/**
* Stop image
*
* @param size The desired image size
* @param color The desired tint color
*/
+ (UIImage *) stopImageWithSize:(CGSize)size color:(UIColor *)color;

@end
27 changes: 27 additions & 0 deletions RTSMediaPlayer/RTSMediaPlayerIconTemplate.m
Expand Up @@ -63,6 +63,28 @@ + (UIBezierPath *) pauseBezierPathWithSize:(CGSize)size
return pauseBezierPath;
}

+ (UIBezierPath *) stopBezierPathWithSize:(CGSize)size
{
CGFloat marginX = 0;
CGFloat marginY = 0;

if (size.width > size.height) {
marginX += (size.width - size.height) / 2.f;
}
else if (size.height > size.width) {
marginY += (size.height - size.width) / 2.f;
}

UIBezierPath *stopBezierPath = [UIBezierPath bezierPath];
[stopBezierPath moveToPoint:CGPointMake(marginX, marginY)];
[stopBezierPath addLineToPoint:CGPointMake(size.width - 2*marginX, marginY)];
[stopBezierPath addLineToPoint:CGPointMake(size.width - 2*marginX, size.height - 2*marginY)];
[stopBezierPath addLineToPoint:CGPointMake(marginX, size.height - 2*marginY)];
[stopBezierPath closePath];

return stopBezierPath;
}

#pragma mark - Images

+ (UIImage *) playImageWithSize:(CGSize)size color:(UIColor *)color
Expand All @@ -75,4 +97,9 @@ + (UIImage *) pauseImageWithSize:(CGSize)size color:(UIColor *)color
return [self imageWithBezierPath:[self pauseBezierPathWithSize:size] size:size color:color];
}

+ (UIImage *) stopImageWithSize:(CGSize)size color:(UIColor *)color
{
return [self imageWithBezierPath:[self stopBezierPathWithSize:size] size:size color:color];
}

@end
23 changes: 23 additions & 0 deletions RTSMediaPlayer/RTSMediaPlayerPlaybackButton.h
Expand Up @@ -6,6 +6,24 @@

#import <UIKit/UIKit.h>

/**
* Behaviors supported by the playback button
*/
typedef NS_ENUM(NSInteger, RTSMediaPlayerPlaybackButtonBehavior) {
/**
* Default behavior (play / pause)
*/
RTSMediaPlayerPlaybackButtonBehaviorDefault,
/**
* Play / pause only for on-demand and DVR streams. Play / stop for live streams
*/
RTSMediaPlayerPlaybackButtonBehaviorStopForLiveOnly,
/**
* Play / stop only for all kinds of streams
*/
RTSMediaPlayerPlaybackButtonBehaviorStopForAll
};

// Forward declarations
@class RTSMediaPlayerController;

Expand All @@ -29,4 +47,9 @@
@property (nonatomic) IBInspectable UIColor *normalColor;
@property (nonatomic) IBInspectable UIColor *hightlightColor;

/**
* Button behavior. Default is RTSMediaPlayerPlaybackButtonBehaviorDefault
*/
@property (nonatomic) RTSMediaPlayerPlaybackButtonBehavior behavior;

@end
18 changes: 15 additions & 3 deletions RTSMediaPlayer/RTSMediaPlayerPlaybackButton.m
Expand Up @@ -48,7 +48,12 @@ - (void)play

- (void)pause
{
[self.mediaPlayerController pause];
if (self.behavior == RTSMediaPlayerPlaybackButtonBehaviorStopForLiveOnly || self.behavior == RTSMediaPlayerPlaybackButtonBehaviorStopForAll) {
[self.mediaPlayerController reset];
}
else {
[self.mediaPlayerController pause];
}
[self refreshButton];
}

Expand All @@ -63,8 +68,15 @@ - (void)refreshButton
UIImage *normalImage = nil;
UIImage *highlightedImage = nil;
if (isPlaying) {
normalImage = [RTSMediaPlayerIconTemplate pauseImageWithSize:self.bounds.size color:self.normalColor];
highlightedImage = [RTSMediaPlayerIconTemplate pauseImageWithSize:self.bounds.size color:self.hightlightColor];
if ((self.behavior == RTSMediaPlayerPlaybackButtonBehaviorStopForLiveOnly && self.mediaPlayerController.streamType == RTSMediaStreamTypeLive)
|| self.behavior == RTSMediaPlayerPlaybackButtonBehaviorStopForAll) {
normalImage = [RTSMediaPlayerIconTemplate stopImageWithSize:self.bounds.size color:self.normalColor];
highlightedImage = [RTSMediaPlayerIconTemplate stopImageWithSize:self.bounds.size color:self.hightlightColor];
}
else {
normalImage = [RTSMediaPlayerIconTemplate pauseImageWithSize:self.bounds.size color:self.normalColor];
highlightedImage = [RTSMediaPlayerIconTemplate pauseImageWithSize:self.bounds.size color:self.hightlightColor];
}
}
else {
normalImage = [RTSMediaPlayerIconTemplate playImageWithSize:self.bounds.size color:self.normalColor];
Expand Down
6 changes: 1 addition & 5 deletions RTSMediaPlayer/RTSMediaSegmentsController.m
Expand Up @@ -211,11 +211,7 @@ - (void)playSegment:(id<RTSMediaSegment>)segment
}

if ([self.playerController.identifier isEqualToString:segment.segmentIdentifier]) {
[self.playerController seekToTime:segment.timeRange.start completionHandler:^(BOOL finished) {
if (finished) {
[self.playerController play];
}
}];
[self.playerController playAtTime:segment.timeRange.start];
}
else {
[self.playerController playIdentifier:segment.segmentIdentifier];
Expand Down
16 changes: 16 additions & 0 deletions RTSMediaPlayer/RTSTimeSlider.h
Expand Up @@ -7,6 +7,16 @@
#import <CoreMedia/CoreMedia.h>
#import <UIKit/UIKit.h>

/**
* The slider knob position when a live stream is played (the knob itself cannot be moved). The default value is left,
* as for the standard iOS playback controller
*/
typedef NS_ENUM(NSInteger, RTSTimeSliderLiveKnobPosition) {
RTSTimeSliderLiveKnobPositionDefault = 0,
RTSTimeSliderLiveKnobPositionLeft = RTSTimeSliderLiveKnobPositionDefault,
RTSTimeSliderLiveKnobPositionRight
};

// Forward declarations
@class RTSMediaPlayerController;
@protocol RTSTimeSliderDelegate;
Expand Down Expand Up @@ -77,6 +87,12 @@
*/
@property (nonatomic, assign, getter=isSeekingDuringTracking) BOOL seekingDuringTracking;

/**
* The position of the slider knob when playing a live stream. Defaults to RTSTimeSliderLiveKnobPositionDefault (left
* position)
*/
@property (nonatomic, assign) RTSTimeSliderLiveKnobPosition knobLivePosition;

@end

/**
Expand Down

0 comments on commit d6ecc22

Please sign in to comment.