Get video code from Youtube Link || Youtube video code


Want to fetch the Youtube video code from the youtube url to play youtube video?

Integrate youtube video ??? Then its the right place using this method you can fetch the video code out from entire youtube link


Android youtube tutorial 



MVk342D7oMQ   is the video code for the above video url using which you can play youtube video



public static String getYoutubeVideoId(String youtubeUrl)
 String video_id="";
 if (youtubeUrl != null && youtubeUrl.trim().length() > 0 && youtubeUrl.startsWith("http"))

String expression = "^.*(("+ "\\/)" + "|(v\\/)|(\\/u\\/w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*"; // var regExp = /^.*((\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
 CharSequence input = youtubeUrl;
 Pattern pattern = Pattern.compile(expression,Pattern.CASE_INSENSITIVE);
 Matcher matcher = pattern.matcher(input);
 if (matcher.matches())
 String groupIndex1 =;
 if(groupIndex1!=null && groupIndex1.length()==11)
 video_id = groupIndex1;
 return video_id;


Show Buttons
Hide Buttons
Read previous post:
Android play youtube video|| how to play video in app

  Android Youtube Player: Android Youtube Player, have you ever tried integrating Youtube Player into your app?  yes its possible...