Search code examples
androidandroid-studioandroid-youtube-api

Getting YouTube video length in Android Studio


I'm creating an app which will display YouTube video. I want to get the length of that video. For example: When the user watches YouTube video for 30 seconds they will get 20 points. Is there any way to get the length. Thanks in advance.


Solution

  • Use YouTubePlayer.getDurationMillis() to obtain the video duration in milliseconds.