【问题标题】:Preview from YouTube-Videos从 YouTube 视频预览
【发布时间】:2013-04-10 00:09:54
【问题描述】:

我想开发一个在 ListView 中显示 YouTube 视频的应用。 就像原始的 YouTube 应用程序一样,但没有视频加载。只有一个显示视频的 ListView,然后单击即可转到加载视频的 YouTube 应用程序。

但是如何在我的应用中显示视频预览?我可以使用 API 或其他技巧吗? 我的第一个想法是我从每个视频中制作一个图像......但是..是的! :)

这是一个示例图像

【问题讨论】:

    标签: android android-listview youtube-api


    【解决方案1】:

    您可以向该地址发送 http 帖子:

    http://www.youtube.com/oembed?url={complete youtube url}&format=json
    

    其中 {complete youtube url} 是视频的完整网址。

    例如:

    http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=AJ0sW7KOFhU&format=json
    

    应该回答你这个 JSON:

    {
    author_url: "http://www.youtube.com/user/neiljohnson666",
    version: "1.0",
    provider_name: "YouTube",
    provider_url: "http://www.youtube.com/",
    thumbnail_url: "http://i2.ytimg.com/vi/AJ0sW7KOFhU/hqdefault.jpg",
    author_name: "Neil Johnson",
    type: "video",
    width: 480,
    height: 270,
    title: "Manowar - Warriors of the World HD",
    thumbnail_width: 480,
    html: "<iframe width="480" height="270" src="http://www.youtube.com/embed/AJ0sW7KOFhU?        feature=oembed" frameborder="0" allowfullscreen></iframe>",
    thumbnail_height: 360
    }
    

    所以 thumbnail_url 就是你要找的图片:

    希望对您有所帮助,干杯!

    【讨论】:

    • 谢谢。这有点帮助。它很酷是的。我还能得到视频的时间长度吗?
    • 当然,试试这个:gdata.youtube.com/feeds/api/videos/… 其中 AJ0sW7KOFhU 是 youtube 视频 ID,有一个包含视频持续时间的字段
    • 兄弟在任何地方举起你的手,我们是世界的勇士!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-29
    • 1970-01-01
    • 1970-01-01
    • 2018-05-08
    • 2019-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多