Is Android Youtube API Using Official Youtube App for playing video?

给你一囗甜甜゛ 提交于 2019-12-20 04:19:53

问题


I used Youtube api for android to develop an app. Even though i create app and it works fine. Still i was not able to Find out what this api really do

1) When i run it on device android 2.2 for first time . It force me to download new updtaes for Official YouTube app from Google play store . After that it works fine and didn't ask for further updation or download of YouTube app . So is YouTube api uses Youtube app for palying video By going through the api code i found out something

public static Intent createVideoIntent(Activity paramActivity, 
String paramString1, String paramString2, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
{
   return a(newIntent("com.google.android.youtube.api.StandalonePlayerActivity.START").putExtra
        ("video_id", paramString2), paramActivity, paramString1, paramInt, paramBoolean1, paramBoolean2);
}

When i look inside YouTube app code i find a activity classnamed StandalonePlayerActivity. But the video is playing inside the UI container designed by me using com.google.android.youtube.player.YouTubePlayerView which is a part of Youtube api . So what is api doing with the above activity class(StandalonePlayerActivity), what is its role?

2)It didn't work on Android 2.1 ,why is it so ?

Please somebody explain this?


回答1:


The YouTube API is used to add YouTube playback to your app. Which means you will be able to embed a YouTube video within the interface of your app. Yes, it does need the official YouTube client to be installed, since that's what will be giving you the playback code, and the ability to play videos. But you don't need to run it, the video will be within your app.

I haven't checked, but it's logical to assume that com.google.android.youtube.player.YouTubePlayerView is a View implemented in the YouTube official app, that will be injected in your app using the YouTube API, which will be rendering the video. Simple as that.

Regarding your last question - the YouTube API docs does mention it will be available on devices running Android 2.2 (Froyo)



来源:https://stackoverflow.com/questions/14229708/is-android-youtube-api-using-official-youtube-app-for-playing-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!