Pratik Lamichhane Pratik Lamichhane - 28 minutes ago 2
Android Question

how to play Any YouTube video play in full screen in android app(android studio)

I am making a android apps which is related to YouTube video i saw in my android apps that will not play full screen how to write code how to play any YouTube video in full screen please help me i am a beginner


Well, if you want a fancy way of doing that (with a little bit more effort) and without opening the Native Youtube App or Youtube in a browser, you can use Youtube Data Api. If you decide to do it this way, I can edit this with some code snippets that might be helpfull :)


public class YoutubeFragment extends Fragment {
private YoutubePlayer mPlayer;
private static String VIDEO_ID;

private final static String API_KEY = "your_api_key";
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    YouTubePlayerSupportFragment youTubePlayerFragment = YouTubePlayerSupportFragment.newInstance();

    FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    transaction.add(, youTubePlayerFragment).commit();

    youTubePlayerFragment.initialize(API_KEY, new OnInitializedListener() {

        public void onInitializationSuccess(Provider provider, final YouTubePlayer player, boolean wasRestored) {

            if (!wasRestored) {
                mPlayer = player;

        public void onInitializationFailure(Provider provider, YouTubeInitializationResult error) {
            // YouTube error
            String errorMessage = error.toString();
            Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show();
            Log.d("errorMessage:", errorMessage);


    return rootView;

this is to make the video as a fragment of your activity(since you work in an app you probably need it this way). It will go straight to full screen(if you don't want to, comment mPlayer.setFullscreen(true) ) and will auto play your video. Hope this will help you

For a simpler way you could simple get this which is using the YoutubeBaseActivity as the superclass. All you need is the youtube video ID.