Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 30daad0694 |
@@ -1,3 +1,7 @@
|
||||
⚠️⚠️⚠️
|
||||
This library has been deprecated and will be removed in the future. Use [PlayerKit](https://github.com/vimeo/PlayerKit) instead.
|
||||
⚠️⚠️⚠️
|
||||
|
||||
# VIMVideoPlayer
|
||||
|
||||
`VIMVideoPlayer` is a simple wrapper around the [AVPlayer](https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVPlayer_Class/index.html) and [AVPlayerLayer](https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVPlayerLayer_Class/index.html#//apple_ref/occ/cl/AVPlayerLayer) classes.
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
@class VIMVideoPlayer;
|
||||
|
||||
static const float TimeUpdateInterval = 0.1f;
|
||||
|
||||
@protocol VIMVideoPlayerDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
static const float DefaultPlayableBufferLength = 2.0f;
|
||||
static const float DefaultVolumeFadeDuration = 1.0f;
|
||||
static const float TimeObserverInterval = 0.01f;
|
||||
|
||||
NSString * const kVideoPlayerErrorDomain = @"kVideoPlayerErrorDomain";
|
||||
|
||||
@@ -98,8 +99,6 @@ static void *VideoPlayer_PlayerItemLoadedTimeRangesContext = &VideoPlayer_Player
|
||||
self.muted = NO;
|
||||
self.looping = NO;
|
||||
|
||||
self.player.usesExternalPlaybackWhileExternalScreenIsActive = YES;
|
||||
|
||||
[self setVolume:1.0f];
|
||||
[self enableTimeUpdates];
|
||||
[self enableAirplay];
|
||||
@@ -165,8 +164,7 @@ static void *VideoPlayer_PlayerItemLoadedTimeRangesContext = &VideoPlayer_Player
|
||||
|
||||
[self resetPlayerItemIfNecessary];
|
||||
|
||||
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithAsset: asset];
|
||||
|
||||
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithAsset:asset automaticallyLoadedAssetKeys:@[NSStringFromSelector(@selector(tracks))]];
|
||||
if (!playerItem)
|
||||
{
|
||||
[self reportUnableToCreatePlayerItem];
|
||||
@@ -644,7 +642,7 @@ static void *VideoPlayer_PlayerItemLoadedTimeRangesContext = &VideoPlayer_Player
|
||||
}
|
||||
|
||||
__weak typeof (self) weakSelf = self;
|
||||
self.timeObserverToken = [self.player addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(TimeUpdateInterval, NSEC_PER_SEC) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
|
||||
self.timeObserverToken = [self.player addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(TimeObserverInterval, NSEC_PER_SEC) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
|
||||
|
||||
__strong typeof (self) strongSelf = weakSelf;
|
||||
if (!strongSelf)
|
||||
@@ -721,29 +719,12 @@ static void *VideoPlayer_PlayerItemLoadedTimeRangesContext = &VideoPlayer_Player
|
||||
NSLog(@"Video player Status Failed: player item error = %@", self.player.currentItem.error);
|
||||
NSLog(@"Video player Status Failed: player error = %@", self.player.error);
|
||||
|
||||
// First, try to use the player error if it exists
|
||||
|
||||
NSError *error = self.player.error;
|
||||
|
||||
// Otherwise try to use the current item's error
|
||||
|
||||
if (!error)
|
||||
{
|
||||
error = self.player.currentItem.error;
|
||||
}
|
||||
|
||||
// If there's a more specific underlyng error, use that
|
||||
|
||||
NSError *underlyingError = [error.userInfo objectForKey:NSUnderlyingErrorKey];
|
||||
|
||||
if (underlyingError)
|
||||
{
|
||||
error = underlyingError;
|
||||
}
|
||||
|
||||
// Finally, construct our own as a last resort
|
||||
|
||||
if (!error)
|
||||
else
|
||||
{
|
||||
error = [NSError errorWithDomain:kVideoPlayerErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"unknown player error, status == AVPlayerItemStatusFailed"}];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user