使用 gdata api 在 android 中集成 youtube 时出现 SAXNotRecognizedException 异常?
我正在将 youtube 集成到我的 Android 应用程序中。我正在使用 gdata youtube 库来实现同样的目的。
`
YouTubeManager ym = new YouTubeManager(clientID);
List<YoutubeVideo> videos;
try {
videos = ym.retrieveVideos(textQuery, maxResults, filter, timeout);
for (YoutubeVideo youtubeVideo : videos) {
System.out.println(youtubeVideo.getWebPlayerUrl());
System.out.println("Thumbnails");
for (String thumbnail : youtubeVideo.getThumbnails()) {
System.out.println("\t" + thumbnail);
}
System.out.println(youtubeVideo.getEmbeddedWebPlayerUrl());
System.out.println("************************************");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} `
我已导入罐子,如下所示, 激活.jar 阿帕奇-mime4j-0.6.jar gdata-core-1.0.jar gdata-media-1.0.jar gdata-youtube-2.0.jar 谷歌收集-1.0-rc2.jar httpmime-4.0.3.jar 邮件.jar servlet.jar
现在我收到一个异常 SAXNotRecognizedException
videos = ym.retrieveVideos(textQuery, maxResults, 过滤器, 超时);
请任何人告诉我这里发生了什么问题。如何修复这个错误?或任何其他方式将 YouTube 集成到 Android 应用程序中。
I am integrating youtube in my android app. I am using gdata youtube library for the same.
`
YouTubeManager ym = new YouTubeManager(clientID);
List<YoutubeVideo> videos;
try {
videos = ym.retrieveVideos(textQuery, maxResults, filter, timeout);
for (YoutubeVideo youtubeVideo : videos) {
System.out.println(youtubeVideo.getWebPlayerUrl());
System.out.println("Thumbnails");
for (String thumbnail : youtubeVideo.getThumbnails()) {
System.out.println("\t" + thumbnail);
}
System.out.println(youtubeVideo.getEmbeddedWebPlayerUrl());
System.out.println("************************************");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} `
I have imported jar's as under,
activation.jar
apache-mime4j-0.6.jar
gdata-core-1.0.jar
gdata-media-1.0.jar
gdata-youtube-2.0.jar
google-collect-1.0-rc2.jar
httpmime-4.0.3.jar
mail.jar
servlet.jar
Now I am getting an exception SAXNotRecognizedException at
videos = ym.retrieveVideos(textQuery, maxResults, filter, timeout);
plz can any one tell me what is happening wrong over here. How to fix this error? Or any other way to integrate youtube in android app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根本原因被报告为问题 9493。
可以在这里找到解决方法:
gdata-core 中的 SecureGenericXMLFactory 故意禁用了某些功能,但其中一些功能需要从 YouTube 检索数据。解决方法的基本思路如下。
(1) 从gdata-core-1.0.jar 中删除原来的SecureGenericXMLFactory
(2) 将原来的gdata-core-1.0.jar 替换为步骤(1) 中创建的新gdata-core-1.0.jar。 (在Eclipse中)
(3) 将SecureGenericXMLFactory的原始源代码复制到您的Android项目中。
(4) 在 SecureSAXParserFactory 的构造函数中,在禁用必要功能的代码行之前添加无条件“返回”。
The root cause is reported as Issue 9493.
And a workaround for it can be found here:
SecureGenericXMLFactory in gdata-core intentionally disables some features, but some of them are needed to retrieve data from YouTube. The basic idea of the work around is as follows.
(1) Remove the original SecureGenericXMLFactory from gdata-core-1.0.jar
(2) Replace the original gdata-core-1.0.jar with the new one created by the step (1). (in Eclipse)
(3) Copy the original source code of SecureGenericXMLFactory to your Android project.
(4) Add an unconditional 'return' in the constructor of SecureSAXParserFactory before the code lines that disable the necessary features.