Video 将应用程序中的视频上传到youTube iphone sdk
我正在尝试将我的应用程序中拍摄的视频上传到YouTube。我已经链接了电影的标题、用户名、密码、路径、长度、关键字、分类以及我的应用程序密钥。然而,当我尝试上传时,我得到了以下消息 2012-12-02 21:29:33.235我的小世界应用程序[12790:907]*GdatServiceBase fetchObjectWithURL:objectClass:objectToPost:ETag:httpMethod:delegate:didFinishSelector:completionHandler:retryInvocationValue:ticket:,/Users/nilesh/GdatObjectiveC client只读/Source/BaseClass/GdatServiceBase.m:549 2012-12-02 21:29:33.238我的小世界应用程序[12790:907]*由于未捕获的异常“NSInternalinconsistenceException”而终止应用程序,原因是:“需要GTMHTTPUploadFetcher” 这是我用来上传它的代码Video 将应用程序中的视频上传到youTube iphone sdk,video,youtube-api,gdata-api,uploading,Video,Youtube Api,Gdata Api,Uploading,我正在尝试将我的应用程序中拍摄的视频上传到YouTube。我已经链接了电影的标题、用户名、密码、路径、长度、关键字、分类以及我的应用程序密钥。然而,当我尝试上传时,我得到了以下消息 2012-12-02 21:29:33.235我的小世界应用程序[12790:907]*GdatServiceBase fetchObjectWithURL:objectClass:objectToPost:ETag:httpMethod:delegate:didFinishSelector:completionHa
- (IBAction)publish: (id) sender;{
self.mProgressView.hidden =NO;
NSString *audioName = [pictureDictionary4 objectForKey:@"photoVideokey"];
NSArray *pathsa = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectorya = [pathsa objectAtIndex:0];
//Get a full path to the image in the documents directory.
NSString *fullPatha = [documentsDirectorya stringByAppendingPathComponent:audioName];
NSError *error = nil;
NSDictionary *attributes = [[NSFileManager defaultManager]
attributesOfItemAtPath:fullPatha error:&error];
if (!error) {
NSNumber *size = [attributes objectForKey:NSFileSize];
}
NSString *devKey = @"xxxxxx";
GDataServiceGoogleYouTube *service = [self youTubeService];
[service setYouTubeDeveloperKey:devKey];
NSString *username = self.accountView.text;
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username];
NSData *data = [NSData dataWithContentsOfFile:fullPatha];
NSString *filename = [pictureDictionary4 objectForKey:@"photoVideokey"];
// gather all the metadata needed for the mediaGroup
NSString *titleStr =self.movieNameField.text;
GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr];
NSString *categoryStr = self.catagoryField.text;
GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:categoryStr];
[category setScheme:kGDataSchemeYouTubeCategory];
NSString *descStr = self.descpView.text;
GDataMediaDescription *desc = [GDataMediaDescription textConstructWithString:descStr];
NSString *keywordsStr = self.tagsField.text;
GDataMediaKeywords *keywords = [GDataMediaKeywords keywordsWithString:keywordsStr];
BOOL isPrivate = NO;
GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup];
[mediaGroup setMediaTitle:title];
[mediaGroup setMediaDescription:desc];
[mediaGroup addMediaCategory:category];
[mediaGroup setMediaKeywords:keywords];
[mediaGroup setIsPrivate:isPrivate];
NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:fullPatha
defaultMIMEType:@"video/mp4"];
// create the upload entry with the mediaGroup and the file data
GDataEntryYouTubeUpload *entry;
entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup
data:data
MIMEType:mimeType
slug:filename];
SEL progressSel = @selector(ticket:hasDeliveredByteCount:ofTotalByteCount:);
[service setServiceUploadProgressSelector:progressSel];
GDataServiceTicket *ticket;
ticket = [service fetchEntryByInsertingEntry:entry
forFeedURL:url
delegate:self
didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)];
[self setUploadTicket:ticket];
NSLog(@"%@",length.text);
NSLog(@"%@",number.text);
NSLog(@"%@",accountView.text);
NSLog(@"%@",tagsField.text);
NSLog(@"%@",catagoryField.text);
NSLog(@"%@",movieNameField.text);
NSLog(@"%@",descpView.text);
NSLog(@"%@",PasswordDisplayField.text);
NSLog(@"%@",ViewingField.text);
NSLog(@"%@",username);
NSLog(@"%@",url);
NSLog(@"%@",filename);
NSLog(@"%@",titleStr);
NSLog(@"%@",category);
NSLog(@"%@",categoryStr);
NSLog(@"%@",descStr);
NSLog(@"%@",desc);
NSLog(@"%@",keywords);
NSLog(@"%@",keywords);
NSLog(@"%@",keywordsStr);
}
- (GDataServiceGoogleYouTube *)youTubeService {
static GDataServiceGoogleYouTube* service = nil;
if (!service) {
service = [[GDataServiceGoogleYouTube alloc] init];
[service setServiceShouldFollowNextLinks:YES];
[service setIsServiceRetryEnabled:YES];
}
// update the username/password each time the service is requested
NSString *username = [accountView text];
NSString *password = [PasswordDisplayField text];
if ([username length] > 0 && [password length] > 0) {
[service setUserCredentialsWithUsername:username
password:password];
} else {
// fetch unauthenticated
[service setUserCredentialsWithUsername:nil
password:nil];
}
NSString *devKey = @"AI39si5rnzA1o82wzQj_kFFJBQRNEPv29OKD9hx6RxLPzvacvfvLFi_uI9eNj0uq8Cul8VQnBbDs4CAvq7ViKq-RnVCgh3OVBQ";
[service setYouTubeDeveloperKey:devKey];
return service;
}
// progress callback
- (void)ticket:(GDataServiceTicket *)ticket
hasDeliveredByteCount:(unsigned long long)numberOfBytesRead
ofTotalByteCount:(unsigned long long)dataLength {
[mProgressView setProgress:(double)numberOfBytesRead / (double)dataLength];
}
// upload callback
- (void)uploadTicket:(GDataServiceTicket *)ticket
finishedWithEntry:(GDataEntryYouTubeVideo *)videoEntry
error:(NSError *)error {
if (error == nil) {
// tell the user that the add worked
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Uploaded!"
message:[NSString stringWithFormat:@"%@ succesfully uploaded",
[[videoEntry title] stringValue]]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!"
message:[NSString stringWithFormat:@"Error: %@",
[error description]]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
}
[mProgressView setProgress: 0.0];
[self setUploadTicket:nil];
}
#pragma mark -
#pragma mark Setters
- (GDataServiceTicket *)uploadTicket {
return mUploadTicket;
}
- (void)setUploadTicket:(GDataServiceTicket *)ticket {
mUploadTicket = ticket;
}
我真的很想知道这方面的一些指导。谢谢听起来你缺少依赖性了
一般来说,如果您在专用或中询问Objective-C GData客户端库的特定问题,您可能会得到更多帮助,因为这实际上是一个实现问题,而不是一个一般的YouTube API问题。听起来您缺少依赖性
一般来说,如果您在专用的或中询问Objective-C GData客户端库的特定问题,您可能会得到更多帮助,因为这实际上是一个实现问题,而不是一个一般的YouTube API问题。我最终通过将所有正确的.h文件添加到我的应用程序并导入它们来完成这部分工作,包括正确的GTMHTTPUploadFetcher文件。谢谢你的帮助。我终于把所有正确的.h文件添加到我的应用程序并导入它们,包括正确的GTMHTTPUploadFetcher文件,使这部分工作起来了。谢谢你的帮助