在 Objective C 上使用 YouTube API 获取元素
我已经阅读了文档,使用了示例项目,甚至检索了在我的应用程序上运行的 YouTube feed,但我无法按照我的意愿显示各个元素。
例如,我可以使用 objectAtIndex:0 获取第一个视频,但随后不知道如何获取标题、id、url 等。这是提要中我的第一个视频的 NSLog。
entry: GDataEntryYouTubeVideo 0x9eb8d50: {v:2.0 title:Evolution of Dance - By Judson Laipply contentSrc:http://www.youtube.com/v/dMH0bHeiRNg?f=standard&d=AVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDm&app=youtube_gdata etag:W/"A0cHQ347eCp7ImA9Wx9UGUo." authors:1 categories:4 links:alternate,video.responses,video.ratings,video.complaints,video.related,self id:tag:youtube.com,2008:video:dMH0bHeiRNg rating:+706815/-62385 comment:GDataComment 0x9ebeb50: {feedLink:GDataFeedLink 0x9ebf2c0: {href:http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/comments countHint:500786 href:http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/comments countHint:500786}} stats:GDataYouTubeStatistics 0x9ebfeb0: {viewCount:164922648 favoriteCount:1010039} mediaGroup:GDataYouTubeMediaGroup 0x9ec0e10: {categories:(
"GDataMediaCategory 0x9ec41f0: {label:Comedy scheme:http://gdata.youtube.com/schemas/2007/categories.cat content:Comedy}"
) contents:(
"GDataMediaContent 0x9ec2df0: {url:http://www.youtube.com/v/dMH0bHeiRNg?f=standard&d=AVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDm&app=youtube_gdata type:application/x-shockwave-flash medium:video isDefault:true expression:full duration:360}",
"GDataMediaContent 0x9ec3620: {url:rtsp://v5.cache7.c.youtube.com/CkcLENy73wIaPgnYRKJ3bPTBdBMYDSANFEgGUghzdGFuZGFyZHIhAVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDmDA==/0/0/0/video.3gp type:video/3gpp medium:video expression:full duration:360}",
"GDataMediaContent 0x9ec39b0: {url:rtsp://v3.cache8.c.youtube.com/CkcLENy73wIaPgnYRKJ3bPTBdBMYESARFEgGUghzdGFuZGFyZHIhAVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDmDA==/0/0/0/video.3gp type:video/3gpp medium:video expression:full duration:360}"
) credits:(
"GDataMediaCredit 0x9ec4730: {role:uploader scheme:urn:youtube content:judsonlaipply}"
) thumbnails:(
"GDataMediaThumbnail 0x9ec4fb0: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/default.jpg height:90 width:120 time:00:03:00 unparsedAttr:yt:name}",
"GDataMediaThumbnail 0x9ec5820: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/hqdefault.jpg height:360 width:480 unparsedAttr:yt:name}",
"GDataMediaThumbnail 0x9ec5bc0: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/1.jpg height:90 width:120 time:00:01:30 unparsedAttr:yt:name}",
"GDataMediaThumbnail 0x9ec5ea0: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/2.jpg height:90 width:120 time:00:03:00 unparsedAttr:yt:name}",
"GDataMediaThumbnail 0x9ec6140: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/3.jpg height:90 width:120 time:00:04:30 unparsedAttr:yt:name}"
) keywords:GDataMediaKeywords 0x9ec66f0: {content:Dancing, comedy keywords:Dancing, comedy} description:GDataMediaDescription 0x9ec4e10: {type:plain content:For more visit http://www.mightaswelldance.com} players:(
"GDataMediaPlayer 0x9ec2e40: {url:http://www.youtube.com/watch?v=dMH0bHeiRNg&feature=youtube_gdata_player}"
) title:GDataMediaTitle 0x9ec6aa0: {type:plain content:Evolution of Dance - By Judson Laipply} duration:360 videoID:dMH0bHeiRNg uploaded:GDataDateTime 0x7359b80: {2006-04-06T21:30:53Z}} accessControls:(
"GDataYouTubeAccessControl 0x9ec0500: {action:comment permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ec0930: {action:commentVote permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ec09f0: {action:videoRespond permission:moderated content:}",
"GDataYouTubeAccessControl 0x9ebeba0: {action:rate permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ebf9f0: {action:embed permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ec0620: {action:list permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ec0b50: {action:syndicate permission:allowed content:}"
) unparsed:<gd:rating>}
I have gone through the documentation, used the sample project and even have the retrieval of a youtube feed working on my app but I am unable to get the individual elements to then displays as I desire.
I am able to get for example the first video using objectAtIndex:0 but then don't know how to get title, id, url, etc. here is an NSLog of my firs video in the feed.
entry: GDataEntryYouTubeVideo 0x9eb8d50: {v:2.0 title:Evolution of Dance - By Judson Laipply contentSrc:http://www.youtube.com/v/dMH0bHeiRNg?f=standard&d=AVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDm&app=youtube_gdata etag:W/"A0cHQ347eCp7ImA9Wx9UGUo." authors:1 categories:4 links:alternate,video.responses,video.ratings,video.complaints,video.related,self id:tag:youtube.com,2008:video:dMH0bHeiRNg rating:+706815/-62385 comment:GDataComment 0x9ebeb50: {feedLink:GDataFeedLink 0x9ebf2c0: {href:http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/comments countHint:500786 href:http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/comments countHint:500786}} stats:GDataYouTubeStatistics 0x9ebfeb0: {viewCount:164922648 favoriteCount:1010039} mediaGroup:GDataYouTubeMediaGroup 0x9ec0e10: {categories:(
"GDataMediaCategory 0x9ec41f0: {label:Comedy scheme:http://gdata.youtube.com/schemas/2007/categories.cat content:Comedy}"
) contents:(
"GDataMediaContent 0x9ec2df0: {url:http://www.youtube.com/v/dMH0bHeiRNg?f=standard&d=AVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDm&app=youtube_gdata type:application/x-shockwave-flash medium:video isDefault:true expression:full duration:360}",
"GDataMediaContent 0x9ec3620: {url:rtsp://v5.cache7.c.youtube.com/CkcLENy73wIaPgnYRKJ3bPTBdBMYDSANFEgGUghzdGFuZGFyZHIhAVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDmDA==/0/0/0/video.3gp type:video/3gpp medium:video expression:full duration:360}",
"GDataMediaContent 0x9ec39b0: {url:rtsp://v3.cache8.c.youtube.com/CkcLENy73wIaPgnYRKJ3bPTBdBMYESARFEgGUghzdGFuZGFyZHIhAVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDmDA==/0/0/0/video.3gp type:video/3gpp medium:video expression:full duration:360}"
) credits:(
"GDataMediaCredit 0x9ec4730: {role:uploader scheme:urn:youtube content:judsonlaipply}"
) thumbnails:(
"GDataMediaThumbnail 0x9ec4fb0: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/default.jpg height:90 width:120 time:00:03:00 unparsedAttr:yt:name}",
"GDataMediaThumbnail 0x9ec5820: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/hqdefault.jpg height:360 width:480 unparsedAttr:yt:name}",
"GDataMediaThumbnail 0x9ec5bc0: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/1.jpg height:90 width:120 time:00:01:30 unparsedAttr:yt:name}",
"GDataMediaThumbnail 0x9ec5ea0: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/2.jpg height:90 width:120 time:00:03:00 unparsedAttr:yt:name}",
"GDataMediaThumbnail 0x9ec6140: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/3.jpg height:90 width:120 time:00:04:30 unparsedAttr:yt:name}"
) keywords:GDataMediaKeywords 0x9ec66f0: {content:Dancing, comedy keywords:Dancing, comedy} description:GDataMediaDescription 0x9ec4e10: {type:plain content:For more visit http://www.mightaswelldance.com} players:(
"GDataMediaPlayer 0x9ec2e40: {url:http://www.youtube.com/watch?v=dMH0bHeiRNg&feature=youtube_gdata_player}"
) title:GDataMediaTitle 0x9ec6aa0: {type:plain content:Evolution of Dance - By Judson Laipply} duration:360 videoID:dMH0bHeiRNg uploaded:GDataDateTime 0x7359b80: {2006-04-06T21:30:53Z}} accessControls:(
"GDataYouTubeAccessControl 0x9ec0500: {action:comment permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ec0930: {action:commentVote permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ec09f0: {action:videoRespond permission:moderated content:}",
"GDataYouTubeAccessControl 0x9ebeba0: {action:rate permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ebf9f0: {action:embed permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ec0620: {action:list permission:allowed content:}",
"GDataYouTubeAccessControl 0x9ec0b50: {action:syndicate permission:allowed content:}"
) unparsed:<gd:rating>}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决,将调用与上面的 xml 进行比较,以便您可以在其他 gdata feed 上使用
resolved, compare the calls with the xml above so that you may use on other gdata feeds