How to play .mp4 video in videoview in android?

前端 未结 6 1885
名媛妹妹
名媛妹妹 2020-12-01 02:47

I am working on video player application, I want to play .mp4 video in native videoview. I am not able to play

6条回答
  •  旧巷少年郎
    2020-12-01 03:15

    Use Like this:

    Uri uri = Uri.parse(URL); //Declare your url here.
    
    VideoView mVideoView  = (VideoView)findViewById(R.id.videoview)
    mVideoView.setMediaController(new MediaController(this));       
    mVideoView.setVideoURI(uri);
    mVideoView.requestFocus();
    mVideoView.start();
    

    Another Method:

      String LINK = "type_here_the_link";
      VideoView mVideoView  = (VideoView) findViewById(R.id.videoview);
      MediaController mc = new MediaController(this);
      mc.setAnchorView(videoView);
      mc.setMediaPlayer(videoView);
      Uri video = Uri.parse(LINK);
      mVideoView.setMediaController(mc);
      mVideoView.setVideoURI(video);
      mVideoView.start();
    

    If you are getting this error Couldn't open file on client side, trying server side Error in Android. and also Refer this. Hope this will give you some solution.

提交回复
热议问题