Auto play video (list view)

How to do auto play, for example facebook in the list, only one video at a time, and pause it when it goes out of focus.

Below is the code for playing video after OnClick, in the video viewing mode in another activity, I want it to scroll and automatically play the video like Facebook.

Videos_URL = intent.getExtras().getString("VideoUrl"); // Find your VideoView in your video_main.xml layout myVideoView = (VideoView) findViewById(R.id.videoview); if (mediaControls == null) { mediaControls = new MediaController(this); } // Create a progressbar progressDialog = new ProgressDialog(this); // Set progressbar title progressDialog.setTitle("APPNAME Video "); // Set progressbar message progressDialog.setMessage("Loading..."); progressDialog.setCancelable(false); // Show progressbar // Show progressbar progressDialog.show(); try { Uri video = Uri.parse(Videos_URL); myVideoView.setVideoURI(video); myVideoView.setMediaController(mediaControls); myVideoView.start(); 

Can I get auto play in video view mode in Android?

+6
source share
1 answer

In the getview mode of the adapter, you like it, it will automatically play the video when it appears on the screen.

 videoView.setVideoPath(videoPath); videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(final MediaPlayer mp) { //seekbar. mp.start(); } catch (Exception e) { e.printStackTrace(); } 
0
source

All Articles