Android Youtube API 是否使用官方 Youtube 应用程序播放视频?

Is Android Youtube API Using Official Youtube App for playing video?(Android Youtube API 是否使用官方 Youtube 应用程序播放视频?)
本文介绍了Android Youtube API 是否使用官方 Youtube 应用程序播放视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?

解决方案

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)

这篇关于Android Youtube API 是否使用官方 Youtube 应用程序播放视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)