Skip to content

Commit

Permalink
Merge branch 'release/2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Sep 11, 2018
2 parents 832af6f + 008ab50 commit 8373b5a
Show file tree
Hide file tree
Showing 53 changed files with 2,082 additions and 602 deletions.
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Carthage
xcuserdata
.DS_Store
report.xml
test_output

*.xcscmblueprint
xcuserdata

archive
build

Carthage

fastlane/report.xml
fastlane/test_output
6 changes: 3 additions & 3 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "SRGSSR/libextobjc" "0.5_srg1"
github "SRGSSR/MAKVONotificationCenter" "1.0_srg1"
github "SRGSSR/srglogger-ios" "1.0.4"
github "SRGSSR/libextobjc" "80a882742fea920587df5c9377af68faa22be5d0"
github "SRGSSR/MAKVONotificationCenter" "120fb5550aee8e9b4c92439bf34533020cc43c44"
github "SRGSSR/srglogger-ios" "1.0.5"
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "SRGSSR/MAKVONotificationCenter" "1.0_srg1"
github "SRGSSR/libextobjc" "0.5_srg1"
github "SRGSSR/srglogger-ios" "1.0.4"
github "SRGSSR/MAKVONotificationCenter" "120fb5550aee8e9b4c92439bf34533020cc43c44"
github "SRGSSR/libextobjc" "80a882742fea920587df5c9377af68faa22be5d0"
github "SRGSSR/srglogger-ios" "1.0.5"
1 change: 0 additions & 1 deletion Demo/Sources/Medias/MediasViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#import "MediaPlayer.h"
#import "MultiPlayerViewController.h"
#import "NSBundle+Demo.h"
#import "Segment.h"
#import "SegmentsPlayerViewController.h"
#import "TimeshiftPlayerViewController.h"

Expand Down
4 changes: 2 additions & 2 deletions Demo/Sources/Models/Media.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#import <Foundation/Foundation.h>

#import "Segment.h"
#import "DemoSegment.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) NSURL *URL;
@property (nonatomic, readonly) BOOL is360;

@property (nonatomic, readonly, nullable) NSArray<Segment *> *segments;
@property (nonatomic, readonly, nullable) NSArray<DemoSegment *> *segments;

@end

Expand Down
6 changes: 3 additions & 3 deletions Demo/Sources/Models/Media.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ @interface Media ()
@property (nonatomic) NSURL *URL;
@property (nonatomic) BOOL is360;

@property (nonatomic) NSArray<Segment *> *segments;
@property (nonatomic) NSArray<DemoSegment *> *segments;

@end

Expand Down Expand Up @@ -48,9 +48,9 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary

self.is360 = [dictionary[@"is360"] boolValue];

NSMutableArray<Segment *> *segments = [NSMutableArray array];
NSMutableArray<DemoSegment *> *segments = [NSMutableArray array];
for (NSDictionary *segmentDictionary in dictionary[@"segments"]) {
Segment *segment = [[Segment alloc] initWithDictionary:segmentDictionary];
DemoSegment *segment = [[DemoSegment alloc] initWithDictionary:segmentDictionary];
[segments addObject:segment];
}
self.segments = [segments copy];
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Players/Inline/InlinePlayerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (instancetype)initWithMedia:(Media *)media
- (IBAction)prepareToPlay:(id)sender
{
self.mediaPlayerController.view.viewMode = self.media.is360 ? SRGMediaPlayerViewModeMonoscopic : SRGMediaPlayerViewModeFlat;
[self.mediaPlayerController prepareToPlayURL:self.media.URL atTime:kCMTimeZero withSegments:nil userInfo:nil completionHandler:^{
[self.mediaPlayerController prepareToPlayURL:self.media.URL atPosition:nil withSegments:nil userInfo:nil completionHandler:^{
self->_ready = YES;
}];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface Segment : NSObject <SRGSegment>
@interface DemoSegment : NSObject <SRGSegment>

- (instancetype)initWithDictionary:(NSDictionary *)dictionary NS_DESIGNATED_INITIALIZER;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// License information is available from the LICENSE file.
//

#import "Segment.h"
#import "DemoSegment.h"

@interface Segment ()
@interface DemoSegment ()

@property (nonatomic, copy) NSString *name;
@property (nonatomic) CMTimeRange srg_timeRange;
Expand All @@ -15,7 +15,7 @@ @interface Segment ()

@end

@implementation Segment
@implementation DemoSegment

#pragma mark Object lifecycle

Expand Down
6 changes: 3 additions & 3 deletions Demo/Sources/Players/Segments/SegmentCollectionViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// License information is available from the LICENSE file.
//

#import "Segment.h"
#import "DemoSegment.h"

#import <CoreMedia/CoreMedia.h>
#import <UIKit/UIKit.h>
Expand All @@ -13,9 +13,9 @@ NS_ASSUME_NONNULL_BEGIN

@interface SegmentCollectionViewCell : UICollectionViewCell

@property (nonatomic, nullable) Segment *segment;
@property (nonatomic, nullable) DemoSegment *segment;

- (void)updateAppearanceWithTime:(CMTime)time selectedSegment:(nullable Segment *)selectedSegment;
- (void)updateAppearanceWithTime:(CMTime)time selectedSegment:(nullable DemoSegment *)selectedSegment;

@end

Expand Down
8 changes: 5 additions & 3 deletions Demo/Sources/Players/Segments/SegmentCollectionViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#import "SegmentCollectionViewCell.h"

#import "CMTimeRange+SRGMediaPlayer.h"

static NSDateComponentsFormatter *SegmentDurationDateComponentsFormatter(void)
{
static NSDateComponentsFormatter *s_dateComponentsFormatter;
Expand All @@ -32,13 +34,13 @@ @implementation SegmentCollectionViewCell

#pragma mark Getters and setters

- (void)setSegment:(Segment *)segment
- (void)setSegment:(DemoSegment *)segment
{
_segment = segment;

self.titleLabel.text = segment.name;

if (! CMTIMERANGE_IS_EMPTY(segment.srg_timeRange)) {
if (SRG_CMTIMERANGE_IS_NOT_EMPTY(segment.srg_timeRange)) {
self.durationLabel.hidden = NO;
self.durationLabel.text = [SegmentDurationDateComponentsFormatter() stringFromTimeInterval:CMTimeGetSeconds(segment.srg_timeRange.duration)];
}
Expand All @@ -61,7 +63,7 @@ - (void)prepareForReuse

#pragma mark UI

- (void)updateAppearanceWithTime:(CMTime)time selectedSegment:(Segment *)selectedSegment
- (void)updateAppearanceWithTime:(CMTime)time selectedSegment:(DemoSegment *)selectedSegment
{
CMTimeRange r = self.segment.srg_timeRange;
float progress = (CMTimeGetSeconds(time) - CMTimeGetSeconds(r.start)) / (CMTimeGetSeconds(CMTimeAdd(r.start, r.duration)) - CMTimeGetSeconds(r.start));
Expand Down
8 changes: 4 additions & 4 deletions Demo/Sources/Players/Segments/SegmentsPlayerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ @interface SegmentsPlayerViewController ()

@property (nonatomic) Media *media;

@property (nonatomic, weak) Segment *selectedSegment;
@property (nonatomic, weak) DemoSegment *selectedSegment;

@property (nonatomic) IBOutlet SRGMediaPlayerController *mediaPlayerController; // top object, strong

Expand Down Expand Up @@ -76,7 +76,7 @@ - (void)viewDidLoad
self.externalPlaybackSwitch.on = self.mediaPlayerController.player.usesExternalPlaybackWhileExternalScreenIsActive;

self.mediaPlayerController.view.viewMode = self.media.is360 ? SRGMediaPlayerViewModeMonoscopic : SRGMediaPlayerViewModeFlat;
[self.mediaPlayerController playURL:self.media.URL atTime:kCMTimeZero withSegments:self.media.segments userInfo:@{ @"test_field" : @"test_value" }];
[self.mediaPlayerController playURL:self.media.URL atPosition:nil withSegments:self.media.segments userInfo:@{ @"test_field" : @"test_value" }];
}

#pragma mark UI
Expand Down Expand Up @@ -117,7 +117,7 @@ - (void)timeSlider:(SRGTimeSlider *)slider isMovingToPlaybackTime:(CMTime)time w
- (UICollectionViewCell *)timelineView:(SRGTimelineView *)timelineView cellForSegment:(id<SRGSegment>)segment
{
SegmentCollectionViewCell *segmentCell = [timelineView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([SegmentCollectionViewCell class]) forSegment:segment];
segmentCell.segment = (Segment *)segment;
segmentCell.segment = (DemoSegment *)segment;
return segmentCell;
}

Expand Down Expand Up @@ -228,7 +228,7 @@ - (void)segmentDidStart:(NSNotification *)notification
{
NSLog(@"Segment did start: %@", notification.userInfo);

Segment *segment = notification.userInfo[SRGMediaPlayerSegmentKey];
DemoSegment *segment = notification.userInfo[SRGMediaPlayerSegmentKey];
if (segment == self.selectedSegment) {
self.selectedSegment = nil;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ - (IBAction)goToLive:(id)sender
if (CMTIMERANGE_IS_INDEFINITE(timeRange) || CMTIMERANGE_IS_EMPTY(timeRange)) {
return;
}

[self.mediaPlayerController seekEfficientlyToTime:CMTimeRangeGetEnd(timeRange) withCompletionHandler:nil];
[self.mediaPlayerController seekToPosition:[SRGPosition positionAroundTime:CMTimeRangeGetEnd(timeRange)] withCompletionHandler:nil];
}

- (IBAction)seek:(id)sender
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Zk8-W1-piv">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Zk8-W1-piv">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="HelveticaNeue.ttc">
<string>HelveticaNeue-Medium</string>
</array>
</customFonts>
<scenes>
<!--Timeshift Player View Controller-->
<scene sceneID="cbS-Cg-mbF">
Expand Down Expand Up @@ -51,8 +46,8 @@
<constraints>
<constraint firstAttribute="height" constant="30" id="ajA-g4-OfO"/>
</constraints>
<color key="minimumTrackTintColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<color key="maximumTrackTintColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<color key="minimumTrackTintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="maximumTrackTintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="thumbTintColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<action selector="seek:" destination="Zk8-W1-piv" eventType="valueChanged" id="uEP-FQ-ZVM"/>
Expand Down
4 changes: 2 additions & 2 deletions Designables/SRGMediaPlayerDesignables.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/

IB_DESIGNABLE
@interface SRGAirplayButton (Designable)
@interface SRGAirPlayButton (Designable)

@end

IB_DESIGNABLE
@interface SRGAirplayView (Designable)
@interface SRGAirPlayView (Designable)

@end

Expand Down
8 changes: 4 additions & 4 deletions Framework/Sources/Categories/AVAudioSession+SRGMediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ OBJC_EXTERN NSString * const SRGMediaPlayerWirelessRouteDidChangeNotification;
@interface AVAudioSession (SRGMediaPlayer)

/**
* Returns `YES` iff Airplay is active (i.e. displaying on an external Airplay device).
* Returns `YES` iff AirPlay is active (i.e. displaying on an external AirPlay device).
*
* @discussion You can listen to the `SRGMediaPlayerWirelessRouteDidChangeNotification` notification to detect route changes.
*/
+ (BOOL)srg_isAirplayActive;
+ (BOOL)srg_isAirPlayActive;

/**
* Return the active Airplay route name if possible. If no route is active, the method returns `nil`.
* Return the active AirPlay route name if possible. If no route is active, the method returns `nil`.
*/
+ (nullable NSString *)srg_activeAirplayRouteName;
+ (nullable NSString *)srg_activeAirPlayRouteName;

@end

Expand Down
4 changes: 2 additions & 2 deletions Framework/Sources/Categories/AVAudioSession+SRGMediaPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ @implementation AVAudioSession (SRGMediaPlayer)

#pragma mark Class methods

+ (BOOL)srg_isAirplayActive
+ (BOOL)srg_isAirPlayActive
{
AVAudioSession *audioSession = [self sharedInstance];
AVAudioSessionRouteDescription *currentRoute = audioSession.currentRoute;
Expand All @@ -32,7 +32,7 @@ + (BOOL)srg_isAirplayActive
return NO;
}

+ (NSString *)srg_activeAirplayRouteName
+ (NSString *)srg_activeAirPlayRouteName
{
AVAudioSession *audioSession = [self sharedInstance];
AVAudioSessionRouteDescription *currentRoute = audioSession.currentRoute;
Expand Down
2 changes: 1 addition & 1 deletion Framework/Sources/Categories/AVPlayer+SRGMediaPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @implementation AVPlayer (SRGMediaPlayer)
// TODO: Remove when iOS 10 is the minimum required version.
- (void)srg_playImmediatelyIfPossible
{
if ([self respondsToSelector:@selector(playImmediatelyAtRate:)]) {
if (@available(iOS 10, *)) {
[self playImmediatelyAtRate:1.f];
}
else {
Expand Down
16 changes: 16 additions & 0 deletions Framework/Sources/Categories/CMTime+SRGMediaPlayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

#import <CoreMedia/CoreMedia.h>

NS_ASSUME_NONNULL_BEGIN

/**
* `CMTIME_IS_INDEFINTE` cannot be tested negatively (gives false positives for invalid times). Use this macro instead.
*/
#define SRG_CMTIME_IS_DEFINITE(time) ((Boolean)(CMTIME_IS_VALID(time) && (((time).flags & kCMTimeFlags_Indefinite) == 0)))

NS_ASSUME_NONNULL_END
23 changes: 23 additions & 0 deletions Framework/Sources/Categories/CMTimeRange+SRGMediaPlayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

#import <CoreMedia/CoreMedia.h>

#import "CMTime+SRGMediaPlayer.h"

NS_ASSUME_NONNULL_BEGIN

/**
* `CMTIMERANGE_IS_EMPTY` cannot be tested negatively (gives false positives for invalid ranges). Use this macro instead.
*/
#define SRG_CMTIMERANGE_IS_NOT_EMPTY(range) ((Boolean)(CMTIMERANGE_IS_VALID(range) && (CMTIME_COMPARE_INLINE(range.duration, !=, kCMTimeZero))))

/**
* `CMTIMERANGE_IS_INDEFINITE` cannot be tested negatively (gives false positives for invalid ranges). Use this macro instead.
*/
#define SRG_CMTIMERANGE_IS_DEFINITE(range) ((Boolean)(CMTIMERANGE_IS_VALID(range) && SRG_CMTIME_IS_DEFINITE(range.start) && SRG_CMTIME_IS_DEFINITE(range.duration)))

NS_ASSUME_NONNULL_END
4 changes: 2 additions & 2 deletions Framework/Sources/Categories/MPVolumeView+SRGMediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface MPVolumeView (SRGMediaPlayer)

/**
* Return the Airplay button within the volume view.
* Return the AirPlay button within the volume view.
*/
@property (nonatomic, readonly) UIButton *srg_airplayButton;
@property (nonatomic, readonly) UIButton *srg_airPlayButton;

@end

Expand Down
2 changes: 1 addition & 1 deletion Framework/Sources/Categories/MPVolumeView+SRGMediaPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@implementation MPVolumeView (SRGMediaPlayer)

- (UIButton *)srg_airplayButton
- (UIButton *)srg_airPlayButton
{
NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
return [evaluatedObject isKindOfClass:[UIButton class]];
Expand Down
12 changes: 7 additions & 5 deletions Framework/Sources/Categories/NSBundle+SRGMediaPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ @implementation NSBundle (SRGMediaPlayer)

+ (NSBundle *)srg_mediaPlayerBundle
{
static NSBundle *bundle;
static dispatch_once_t once;
dispatch_once(&once, ^{
bundle = [NSBundle bundleForClass:[SRGMediaPlayerController class]];
static NSBundle *s_bundle;
static dispatch_once_t s_onceToken;
dispatch_once(&s_onceToken, ^{
NSString *bundlePath = [[NSBundle bundleForClass:[SRGMediaPlayerController class]].bundlePath stringByAppendingPathComponent:@"SRGMediaPlayer.bundle"];
s_bundle = [NSBundle bundleWithPath:bundlePath];
NSAssert(s_bundle, @"Please add SRGMediaPlayer.bundle to your project resources");
});
return bundle;
return s_bundle;
}

@end
Loading

0 comments on commit 8373b5a

Please sign in to comment.