Ahmad
Ahmad

Reputation: 47

Video auto play I want when user click on play button the video play

Video auto play I want when user click on play button the video play.

VideoView videoView =(VideoView)findViewById(R.id.video_view);
    MediaController mediaController= new MediaController(this);
    mediaController.setAnchorView(videoView);
    Uri uri=Uri.parse(selectedItem.getTrailerLink());
    videoView.setMediaController(mediaController);
    videoView.setVideoURI(uri);
    videoView.requestFocus();
    videoView.start();

Upvotes: 1

Views: 297

Answers (1)

Faiz Malkani
Faiz Malkani

Reputation: 313

That's pretty simple: don't call start() right away.

Move that to the onClick method for the button, and you're good to go

Upvotes: 1

Related Questions