Showing posts with label youtube. Show all posts
Showing posts with label youtube. Show all posts

Friday, December 16, 2016

Tutorial Upload/Share Video To Youtube From Own Application

Today i going to share a tutorial about how to share/upload video to youtube from android application that we created.


In this tutorial we'll do some steps, like :
  • Browse the video in your phone gallery
  • Select the video
  • Play the video in VideoView before uploading
  • Upload the video to youtube

For easy to understanding, i created a method for every function, hope you'll get what is the process look likes

Now let's create the layout, give it name activity_main.xml, and then paste the following code :

We used VideoView for display and play the video.

In your java class, there are some method that will called during the process, there are :

1. Select the video from gallery and displaying on the VideoView


2. Generate the video path from gallery

3. Get Content URI From path and share video to youtube


There are the method that i created in this project, hope your understand the process from the begin until the end (Video uploaded).

Here the full code :

That's all tutorial about how to upload/share video to youtube from your android application. Hope it helps

Friday, December 9, 2016

Tutorial Watch Youtube's Video From Own Android Application

Today i going to share a tutorial integrated with Youtube. Exactly how to display youtube video into your own android application.


We using Youtube Android API and must be activated. Then we create the credentials. For more information please go through Youtube Android Player API.

See also how to login using facebook


ACTIVATED THE YOUTUBE API KEY AND GET THE CREDENTIAL


1. Go to Developer Console
2. Create New Project or use an existing project

Create project

3. If you choose to create new project, then fill your project name

Fill the project name

4. Take a look to API Youtube, and click Youtube Data API


Youtube data API

5. Enable the Youtube Data API

Enable

6. Create credential by clicked the button Create Credential


Create the credential

7. Fill the credential field

Credential field

9. Here it is, the credentials

The credentials


That's all the steps how to enable the Youtube API and create the credentials on your project. Now time to start the Android project.



CREATE ANDROID STUDIO PROJECT



Download the latest version of Youtube Android Player API, HERE. Extract the zip file and find the YoutubeAndroidPlayerApi.jar.

Place the YoutubeAndroidPlayerApi.jar in your project's libs folder. Right click on the jar, choose menu Add As Library.

Create one layout :

  1. activity_main.xml
Create two java classes :
  1. Constant.java
  2. MainActivity.java
After you creating all layout and java classes, now modify these layout and java classes one by one. 

Modify your activity_main.xml, paste the following code :

Modify your Constant.java, define your YOUTUBE API KEY and the YOUTUBE VIDEO ID here. You can find out the YOUTUBE VIDEO ID on the URL.

Example the URL is : https://www.youtube.com/watch?v=WhRaCA9bC9k. WhRaCA9bC9k is the video ID.

take a look at the following code :

Last, modify your MainActivity.java, MainActivity.java has to extends YoutubeBaseActivity. Paste the following code :

Don't forget to add INTERNET permission in your AndroidManifest.xml :

<uses-permission android:name="android.permission.INTERNET"/>

DOWNLOAD THE PROJECT HERE : GITHUB LINK