Last active
February 28, 2016 02:53
-
-
Save priore/88b2cbe96ea5f5209763 to your computer and use it in GitHub Desktop.
Check valid MPMoviePlayerController video URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)validVideoURL:(NSString*)url valid:(void(^)())valid invalid:(void(^)())invalid | |
| { | |
| // AFNetworking https://github.com/AFNetworking | |
| AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
| manager.responseSerializer = [AFHTTPResponseSerializer serializer]; | |
| manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/vnd.apple.mpegurl", @"video/mp2t", | |
| @"video/mov", @"video/mpv", @"video/3gp", @"video/mp4", nil]; | |
| NSMutableURLRequest *request = [manager.requestSerializer requestWithMethod:@"HEAD" URLString:url parameters:nil error:nil]; | |
| AFHTTPRequestOperation *operation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
| RAILog(@"%@", operation.response); | |
| if (valid) | |
| valid(); | |
| } failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
| if (operation.response.statusCode == 405) { // method HEAD not support from server | |
| if (valid) | |
| valid(); | |
| } else if (invalid) { | |
| invalid(); | |
| } | |
| }]; | |
| [operation start]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment