Ste*_*fMa 3 android youtube-api android-listview
我想开发一个应用程序,在ListView中显示YouTube视频.就像最初的YouTube-App一样,但没有视频加载.只有一个显示视频的ListView,只需点击一下即可转到加载视频的YouTube应用.
但是如何在我的应用中显示视频预览?我可以使用API或其他技巧吗?我的第一个想法是我从每个视频中做一个图像...但是..是的!:)
这是一个示例图像

你可以发一个http到这个地址的帖子:
http://www.youtube.com/oembed?url={complete youtube url}&format=json
Run Code Online (Sandbox Code Playgroud)
其中{complete youtube url}是视频的完整网址.
例如:
http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=AJ0sW7KOFhU&format=json
Run Code Online (Sandbox Code Playgroud)
应该回答你这个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
}
Run Code Online (Sandbox Code Playgroud)
所以thumbnail_url是你要找的图像:

希望有所帮助,欢呼!
| 归档时间: |
|
| 查看次数: |
1698 次 |
| 最近记录: |