From 937366d829f4abe548a5b269d15eea841a1c189e Mon Sep 17 00:00:00 2001 From: Sergey Petrachkov Date: Thu, 11 May 2017 09:58:01 +0700 Subject: [PATCH 1/3] added error reporting callback to ASVideoNode --- Source/ASVideoNode.h | 26 +++++++++++++++++--------- Source/ASVideoNode.mm | 3 ++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Source/ASVideoNode.h b/Source/ASVideoNode.h index 16f842f42..41b065fe7 100644 --- a/Source/ASVideoNode.h +++ b/Source/ASVideoNode.h @@ -21,14 +21,14 @@ @protocol ASVideoNodeDelegate; typedef NS_ENUM(NSInteger, ASVideoNodePlayerState) { - ASVideoNodePlayerStateUnknown, - ASVideoNodePlayerStateInitialLoading, - ASVideoNodePlayerStateReadyToPlay, - ASVideoNodePlayerStatePlaybackLikelyToKeepUpButNotPlaying, - ASVideoNodePlayerStatePlaying, - ASVideoNodePlayerStateLoading, - ASVideoNodePlayerStatePaused, - ASVideoNodePlayerStateFinished + ASVideoNodePlayerStateUnknown, + ASVideoNodePlayerStateInitialLoading, + ASVideoNodePlayerStateReadyToPlay, + ASVideoNodePlayerStatePlaybackLikelyToKeepUpButNotPlaying, + ASVideoNodePlayerStatePlaying, + ASVideoNodePlayerStateLoading, + ASVideoNodePlayerStatePaused, + ASVideoNodePlayerStateFinished }; NS_ASSUME_NONNULL_BEGIN @@ -110,7 +110,7 @@ NS_ASSUME_NONNULL_BEGIN * @param videoNode The video node. * @param state player state that is going to be set. * @discussion Delegate method invoked when player changes it's state to - * ASVideoNodePlayerStatePlaying or ASVideoNodePlayerStatePaused + * ASVideoNodePlayerStatePlaying or ASVideoNodePlayerStatePaused * and asks delegate if state change is valid */ - (BOOL)videoNode:(ASVideoNode*)videoNode shouldChangePlayerStateTo:(ASVideoNodePlayerState)state; @@ -147,6 +147,13 @@ NS_ASSUME_NONNULL_BEGIN * @param videoNode The videoNode */ - (void)videoNodeDidRecoverFromStall:(ASVideoNode *)videoNode; +/** + * @abstract Delegate method invoked when an error occurs while trying to play a video + * @param videoNode The videoNode. + * @param currentItem The error that occurs + */ +- (void)videoNodeDidFailToInitAssetFor:(ASVideoNode *)videoNode withError:(NSError *)error; + @end @@ -157,3 +164,4 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + diff --git a/Source/ASVideoNode.mm b/Source/ASVideoNode.mm index a8d015045..ad8a189bb 100644 --- a/Source/ASVideoNode.mm +++ b/Source/ASVideoNode.mm @@ -152,7 +152,8 @@ - (void)prepareToPlayAsset:(AVAsset *)asset withKeys:(NSArray *)requ NSError *error = nil; AVKeyValueStatus keyStatus = [asset statusOfValueForKey:key error:&error]; if (keyStatus == AVKeyValueStatusFailed) { - NSLog(@"Asset loading failed with error: %@", error); + NSLog(@"Asset loading failed with error: %@", error); + [self.delegate videoNodeDidFailToInitAssetFor:self withError:error]; } } From f08ddc34de0306549d1e8bd066a160f827a21558 Mon Sep 17 00:00:00 2001 From: Sergey Petrachkov Date: Thu, 11 May 2017 11:22:39 +0700 Subject: [PATCH 2/3] updated Changelog.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b29d26f18..8a37fe272 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,3 +18,4 @@ - [ASDisplayNode] Pass drawParameter in rendering context callbacks [Michael Schneider](https://github.com/maicki)[#248](https://github.com/TextureGroup/Texture/pull/248) - [ASTextNode] Move to class method of drawRect:withParameters:isCancelled:isRasterizing: for drawing [Michael Schneider] (https://github.com/maicki)[#232](https://github.com/TextureGroup/Texture/pull/232) - [ASDisplayNode] Remove instance:-drawRect:withParameters:isCancelled:isRasterizing: (https://github.com/maicki)[#232](https://github.com/TextureGroup/Texture/pull/232) +- [ASVideoNode] Added error reporing to ASVideoNode and it's delegate [#260](https://github.com/TextureGroup/Texture/pull/260) From 86620c53ff5abf2aa5bbcba8c941c918636f595c Mon Sep 17 00:00:00 2001 From: Sergey Petrachkov Date: Thu, 11 May 2017 16:06:19 +0700 Subject: [PATCH 3/3] updated code according to review notes: - preserved two-spaces indentation; - extended error reporting callback with key and asset, updated method call; --- Source/ASVideoNode.h | 26 +++++++++++++------------- Source/ASVideoNode.mm | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/ASVideoNode.h b/Source/ASVideoNode.h index 41b065fe7..41b0f11de 100644 --- a/Source/ASVideoNode.h +++ b/Source/ASVideoNode.h @@ -21,14 +21,14 @@ @protocol ASVideoNodeDelegate; typedef NS_ENUM(NSInteger, ASVideoNodePlayerState) { - ASVideoNodePlayerStateUnknown, - ASVideoNodePlayerStateInitialLoading, - ASVideoNodePlayerStateReadyToPlay, - ASVideoNodePlayerStatePlaybackLikelyToKeepUpButNotPlaying, - ASVideoNodePlayerStatePlaying, - ASVideoNodePlayerStateLoading, - ASVideoNodePlayerStatePaused, - ASVideoNodePlayerStateFinished + ASVideoNodePlayerStateUnknown, + ASVideoNodePlayerStateInitialLoading, + ASVideoNodePlayerStateReadyToPlay, + ASVideoNodePlayerStatePlaybackLikelyToKeepUpButNotPlaying, + ASVideoNodePlayerStatePlaying, + ASVideoNodePlayerStateLoading, + ASVideoNodePlayerStatePaused, + ASVideoNodePlayerStateFinished }; NS_ASSUME_NONNULL_BEGIN @@ -148,12 +148,13 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)videoNodeDidRecoverFromStall:(ASVideoNode *)videoNode; /** - * @abstract Delegate method invoked when an error occurs while trying to play a video + * @abstract Delegate method invoked when an error occurs while trying trying to load an asset * @param videoNode The videoNode. - * @param currentItem The error that occurs + * @param key The key of value that failed to load. + * @param asset The asset. + * @param error The error that occurs. */ -- (void)videoNodeDidFailToInitAssetFor:(ASVideoNode *)videoNode withError:(NSError *)error; - +- (void)videoNode:(ASVideoNode *)videoNode didFailToLoadValueForKey:(NSString *)key asset:(AVAsset *)asset error:(NSError *)error; @end @@ -164,4 +165,3 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END - diff --git a/Source/ASVideoNode.mm b/Source/ASVideoNode.mm index ad8a189bb..ce61ab3b2 100644 --- a/Source/ASVideoNode.mm +++ b/Source/ASVideoNode.mm @@ -152,8 +152,8 @@ - (void)prepareToPlayAsset:(AVAsset *)asset withKeys:(NSArray *)requ NSError *error = nil; AVKeyValueStatus keyStatus = [asset statusOfValueForKey:key error:&error]; if (keyStatus == AVKeyValueStatusFailed) { - NSLog(@"Asset loading failed with error: %@", error); - [self.delegate videoNodeDidFailToInitAssetFor:self withError:error]; + NSLog(@"Asset loading failed with error: %@", error); + [self.delegate videoNode:self didFailToLoadValueForKey:key asset:asset error:error]; } }