Vishal Pawar
Vishal Pawar

Reputation: 4340

video doesn't play with VideoView while play's with native player

Here is my code. In this if I launch the intent with video url it play's while it doesn't play's in videoview is there any way to get it working in VideoView

VideoView mVideoView = new VideoView(this);
String videoURL = "video_url";
mVideoView.setMediaController(new MediaController(this));
mVideoView.setVideoURI(Uri.parse(videoURL));

setContentView(mVideoView);

while this native player plays video

Intent theIntent = new Intent();
theIntent.setDataAndType(Uri.parse(videoURL), "video/*");

I tested this on device also

Upvotes: 3

Views: 3183

Answers (2)

Bibin Jose
Bibin Jose

Reputation: 93

i think this might be helpfull.

VideoView view = (VideoView) findViewById(R.id.xxxx);

MediaController mc = new MediaController(this);
mc.setMediaPlayer(view);
view.setMediaController(mc);
try{
    view.setVideoURI(Uri.parse(file_path));
} catch(){
}
view.requestFocus();
try{
    view.start();   
}catch(){
}

Upvotes: 0

Nirali
Nirali

Reputation: 13805

Try below way

            VideoView videoView = (VideoView) findViewById(R.id.VideoView);
            MediaController mediaController = new MediaController(this);
            mediaController.setAnchorView(videoView);
            // Set video link (mp4 format )
            Uri video = Uri.parse("mp4 video link");
            videoView.setMediaController(mediaController);
            videoView.setVideoURI(video);
            videoView.start();

Refer this link

https://stackoverflow.com/a/6410421/1441666

And also check supported formats Android Supported Media Formats

https://stackoverflow.com/a/8714189/1441666

Upvotes: 2

Related Questions