How to play a video file in android?

后端 未结 6 1838
有刺的猬
有刺的猬 2020-12-29 08:03

I am placed video MP4 to my domain space. I have its public URL, Now i want to play it in my android app; but don\'t know how can I do this. I used following code which is n

6条回答
  •  温柔的废话
    2020-12-29 08:22

    The VideoView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the video so that it can be used in any layout manager, and provides various display options such as scaling and tinting.

    Code:

    videoView = (VideoView)findViewById(R.id.ViewVideo);
    videoView.setVideoURI(Uri.parse(“android.resource://” + getPackageName() +”/”+R.raw.video));
    videoView.setMediaController(new MediaController(this));
    videoView.requestFocus();
    videoView.start();
    

    if you want see source code : Play video file using VideoView in Android

提交回复
热议问题