Skip to content

Commit

Permalink
Merge branch 'release/2.4.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Jul 27, 2018
2 parents 67b7161 + fe3a333 commit 832af6f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Framework/Sources/Controllers/SRGMediaPlayerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ - (void)prepareToPlayItem:(AVPlayerItem *)item
completionHandler:(void (^)(void))completionHandler
{
NSAssert(! targetSegment || [segments containsObject:targetSegment], @"Segment must be valid");
NSAssert(item || URL, @"An item or a URL must be provided");

if (targetSegment) {
// Do not seek to the very beginning, seek slightly after with zero tolerance to be sure to end within the segment
Expand All @@ -793,7 +794,11 @@ - (void)prepareToPlayItem:(AVPlayerItem *)item
time = kCMTimeZero;
}

if (URL) {
if ([item.asset isKindOfClass:[AVURLAsset class]]) {
AVURLAsset *asset = (AVURLAsset *)item.asset;
URL = asset.URL;
}
else {
item = [AVPlayerItem playerItemWithURL:URL];
}

Expand Down
4 changes: 2 additions & 2 deletions SRGMediaPlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 2.4.3;
MARKETING_VERSION = 2.4.4;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -1255,7 +1255,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 2.4.3;
MARKETING_VERSION = 2.4.4;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Sources/PlaybackTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ - (void)testPrepareWithItem
XCTAssertEqual(self.mediaPlayerController.playbackState, SRGMediaPlayerPlaybackStatePreparing);
}];

XCTAssertNil(self.mediaPlayerController.contentURL);
XCTAssertEqualObjects(self.mediaPlayerController.contentURL, OnDemandTestURL());
XCTAssertEqualObjects(self.mediaPlayerController.playerItem, playerItem);

TestAssertIndefiniteTime(self.mediaPlayerController.seekStartTime);
Expand Down
15 changes: 15 additions & 0 deletions docs/Getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ For proper integration into the control center and the lock screen, use the `MPR
Note that control center integration does not work in the iOS simulator, you will need a real device for tests.
## Custom resource loading and FairPlay support
If you need to customize the resource loading process (e.g. to unencrypt stream chunks on-the-fly or to optimize the way they are retrieved), create a dedicated `AVAssetResourceLoaderDelegate` class. Then play an `AVPlayerItem` built from an asset which this delegate has been assigned to:
```objective-c
AVURLAsset *asset = ...;
[asset.resourceLoader setDelegate:resourceLoaderDelegate queue:queue];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
[self.mediaPlayerController playItem:playerItem];
```

where `resourceLoaderDelegate` is an instance of your custom resource loader delegate class, and `queue` is the queue on which events must be dispatched.

In particular, FairPlay requires the use of a custom resource loader delegate for license retrieval. Please refer to the [official FairPlay documentation](https://developer.apple.com/streaming/fps) for more information.

## Thread-safety

The library is intended to be used from the main thread only.
Expand Down

0 comments on commit 832af6f

Please sign in to comment.