Showing a video in a VideoView by its URL

65 Views Asked by At

I am trying to load a video in VideoView in my app but when I open it, it says that it can't play this video. This is my code:

video=findViewById(R.id.mainVideoView);                     

    Uri uri = Uri.parse("https://www.google.com/url?sa=t&source=web&rct=j&url=https://m.youtube.com/watch%3Fv%3DlLVrP_nzvB8&ved=2ahUKEwjjxtCQ_abgAhVUuXEKHTdUAggQwqsBMAR6BAgHEAU&usg=AOvVaw29VZ4OKcAgFXwyBjLjgTcN");
    video.setVideoURI(uri);
    MediaController mc = new MediaController(MainActivity.this);
    video.setMediaController(mc);
    video.requestFocus();
    video.start();
1

There are 1 best solutions below

0
Tanzeela Nisar On

you can't play youtube videos by using videoView as you mention in your question. kindly use this library, that allows you to play youtube videos in your android app. youtube_android_player_api