androidvideoyoutubeandroid-videoviewandroid-video-player

Unable to play video in videoview from youtube url


I want to play following youtube url in android VideoView but it is not streaming video

https://www.youtube.com/watch?v=h-gEwftyPCg

Following is my code

   VideoView videoView = (VideoView) getView().findViewById(R.id.dealVideo);
        MediaController mc = new MediaController(getContext());
        mc.setAnchorView(videoView);
        mc.setMediaPlayer(videoView);
        videoView.setVideoURI(Uri.parse("https://www.youtube.com/watch?v=h-gEwftyPCg"));
        videoView.start();

I want to support non youtube video url as well


Solution

  • You can not play youtube link directly in VideoView.

    You need to integrate youtube player.

    Check this out how to do that: https://developers.google.com/youtube/android/player/