How to play videos on android [closed]

-2

I want to run a video in the background as a standby screen, hiding player controls etc.

    
asked by anonymous 02.03.2016 / 20:29

1 answer

1

Good night, Android offers a broad API for running media, the easiest way for you to play videos is by using VideoView which is a MediaPlayer wrapper and SurfaceView.

Simple example, add the VideoView element in the xml layout and Java code:

    VideoView videoView = (VideoView) 
                        findViewById(R.id.videoView);

    videoView.setVideoPath(
             "uri da mídia");

    MediaController mediaController = new 
        MediaController(this);
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);
    videoView.start();      
    
03.03.2016 / 01:30