Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
If we want to show the video to our android application then we do not store the video inside the project, this will increase the app size. So instead, we can upload the video to YouTube and stream it in the app to decreases the app size.
So In this blog,
I have shown you how to play the video in your own android app.
We have been already interacting with Google APIs, So we need to get the Google Developer API Key first.
Follow below steps to obtain your Google Developer Android API Key.
Open the layout file of your activity (activity_main.xml) and add below code. This creates a simple layout with YouTubePlayerView.
For YouTubePlayerView
activity_main.xml
A view for displaying YouTube videos. Using this View directly is an alternative to using theYouTubePlayerFragment. If you choose to use this view directly, your activity needs to extend YouTubeBaseActivity.
YouTubePlayerFragment
YouTubeBaseActivity
To get started, place this view in your view hierarchy and call initialize(String, OnInitializedListener) to create a YouTubePlayer which you can use to load videos into this View.
initialize(String, OnInitializedListener)
YouTubePlayer
This view will save and restore the state of the YouTubePlayer associated with the view as part of the onSaveInstanceState/onRestoreInstanceState flow.
onSaveInstanceState
onRestoreInstanceState
This activity also contains few initialization listener methods to know the status of the youtube player.
MainActivity.java
Maybe this tutorial is worked for you.
Source:
https://developers.google.com/youtube/
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.