0
我已經開發了加載用戶的視頻時,他們單擊該單元格中的tableview它去保存一堆不同的信息的另一個視圖 - 控制的應用程序。提取的YouTube視頻鏈接使用YouTube數據API
我試圖從特定的視頻實際的YouTube鏈接。我打印出我得到的鏈接,並以這種形式出現。
https://www.youtube.com/v/Xf5pXlZJr1U?version=3&f=user_uploads&app=youtube_gdata
但我希望它是這種形式。
http://www.youtube.com/watch?v=Xf5pXlZJr1U
原因是,我希望人們能分享通過社交媒體的聯繫,但它出來奇怪時,它的第一格式。
有什麼辦法可以輕鬆地轉換的鏈接?
示例代碼和答案編輯
GDataEntryBase *entry2 = [[feed entries] objectAtIndex:indexPath.row];
NSString *title = [[entry2 title] stringValue];
NSArray *contents = [[(GDataEntryYouTubeVideo *)entry2 mediaGroup] mediaContents];
GDataMediaContent *flashContent = [GDataUtilities firstObjectFromArray:contents withValue:@"application/x-shockwave-flash" forKeyPath:@"type"];
NSString *tempURL = [flashContent URLString];
NSArray *thumbnails = [[(GDataEntryYouTubeVideo *)entry2 mediaGroup] mediaThumbnails];
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[thumbnails objectAtIndex:0] URLString]]];
UIImage *image = [UIImage imageWithData:data];
GDataYouTubeMediaGroup *mediaGroup = [(GDataEntryYouTubeVideo *)entry2 mediaGroup];
GDataMediaDescription *desc2 = [mediaGroup mediaDescription];
NSString *mystring = [desc2 stringValue];
NSArray *listItems = [tempURL componentsSeparatedByString:@"/"];
NSString *NewURL = @"";
NewURL = [NewURL stringByAppendingString:[listItems objectAtIndex:0]];
NewURL = [NewURL stringByAppendingString:@"//"];
NewURL = [NewURL stringByAppendingString:[listItems objectAtIndex:2]];
NewURL = [NewURL stringByAppendingString:@"/"];
NewURL = [NewURL stringByAppendingString:@"watch"];
NewURL = [NewURL stringByAppendingString:@"?v="];
NSArray *listItems2 = [[listItems objectAtIndex:4] componentsSeparatedByString:@"?"];
NewURL = [NewURL stringByAppendingString:[listItems2 objectAtIndex:0]];
添加一些代碼和YouTube API使用 – 2013-03-06 20:10:37
你去那裏。我給了一些代碼。 – 2013-03-06 20:18:23
api ??請包括api – 2013-03-06 20:22:33