Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added error reporting callback to ASVideoNode #260

Merged
merged 3 commits into from
May 11, 2017
Merged

added error reporting callback to ASVideoNode #260

merged 3 commits into from
May 11, 2017

Conversation

SergeyPetrachkov
Copy link
Contributor

@SergeyPetrachkov SergeyPetrachkov commented May 11, 2017

here is a simple implementation of error reporter to ASVideoNodeDelegate. Once asset is failed to load an item - it reports to it's delegate that the error has occured

(huy: Closes #252)

@CLAassistant
Copy link

CLAassistant commented May 11, 2017

CLA assistant check
All committers have signed the CLA.

@ghost
Copy link

ghost commented May 11, 2017

🚫 CI failed with log

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! A few changes requested but the use case is legitimate so we should try to merge this sooner rather than later.

ASVideoNodePlayerStatePlaying,
ASVideoNodePlayerStateLoading,
ASVideoNodePlayerStatePaused,
ASVideoNodePlayerStateFinished
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reserve the old indentation.

* @param videoNode The videoNode.
* @param currentItem The error that occurs
*/
- (void)videoNodeDidFailToInitAssetFor:(ASVideoNode *)videoNode withError:(NSError *)error;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To follow convention, let's make it -(void)videoNode:(ASVideoNode *)videoNode didFailToLoadAssetWithError:(NSError *)error.

* @param currentItem The error that occurs
*/
- (void)videoNodeDidFailToInitAssetFor:(ASVideoNode *)videoNode withError:(NSError *)error;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a newline already. Please remove this one.

@@ -152,7 +152,8 @@ - (void)prepareToPlayAsset:(AVAsset *)asset withKeys:(NSArray<NSString *> *)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];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pass along the asset and maybe the key at hand? I imagine those objects might be helpful for investigations. Should be something like -(void)videoNode:(ASVideoNode *)videoNode didFailToLoadValueForKey:(NSString *)key asset:(AVAsset *)asset error:(NSError *)error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, please use 2 spaces for indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is updated.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "while trying to load an asset".

@SergeyPetrachkov
Copy link
Contributor Author

I've updated the code according to your notes. The only thing that bothers me is that once it's going to swift it gets not pretty:

func videoNode(_ videoNode: ASVideoNode, didFailToLoadValueForKey key: String, asset: AVAsset, error: Error)

anyway, swift developers are used to objective-c to swift bridging and naming adventures.

- preserved two-spaces indentation;
- extended error reporting callback with key and asset, updated method call;
@nguyenhuy
Copy link
Member

@petrachkov Good point regarding the Swift API. How can we improve it?

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we should improve the Swift API, it's not a blocking issue.

@SergeyPetrachkov
Copy link
Contributor Author

@nguyenhuy Well, you'll have to redesign the whole concept of namings in Texture, e.g. every method of ASVideoNodeDelegate comes with

_ videoNode: ASVideoNode

I don't see a problem here for swift developers as long as there is going to be swift4 and who knows how will it look like then.

@nguyenhuy
Copy link
Member

OK. Let's merge this PR then. Thanks again!

@nguyenhuy nguyenhuy merged commit 4b114e8 into TextureGroup:master May 11, 2017
@maicki
Copy link
Contributor

maicki commented May 11, 2017

@nguyenhuy It would be a huge effort, but we could use macros like NS_SWIFT_NAME, NS_SWIFT_UNAVAILABLE, NS_REFINED_FOR_SWIFT and NS_SWIFT_NOTHROW to make our Objective-C API play a bit better with Swift. Although this would basically be an API breaking change as the API will be exported to Swift differently as it's currently is. cc @garrettmoon

@SergeyPetrachkov SergeyPetrachkov deleted the ASVideoNode_Error_Callback branch May 12, 2017 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants