Access Youtube Video via Android app

Youtube video are provided with a distinct key like - 

1. You need to download Youtube supporting library from here
    and add paste it to the lib folder of app followed by adding it to gradle file as shown below.
compile files('libs/YouTubeAndroidPlayerApi.jar')

2. Sync your project
3. Once you have the key, add the below code in your activity-
      if (YouTubeIntents.canResolvePlayVideoIntentWithOptions(this)) {
         //Opens in the YouTube app in fullscreen and returns to this app once the video finishes
         
           startActivity(
            YouTubeIntents.createPlayVideoIntentWithOptions(context, video.getKey(), true, true)
          );

     }


Thats It!

Comments

Popular posts from this blog

@Overrride annotation introduced in Java1.5

Liskov Substitution Principle (LSP)

Interface Segregation Principle