Brijesh Thakur
Brijesh Thakur

Reputation: 6778

Play mp4 Video using <Embed> tag on Android Webview

I want to play mp4 video using tag on Webview. I have few constraints for not to use HTML5 tag. I have looked code to play YouTube video on webview. But YouTube uses .flv format. I have .mp4 video to play.

Thanks in advance.

Upvotes: 2

Views: 969

Answers (1)

Andy
Andy

Reputation: 7127

You could play the video directly, without a WebView:

VideoView videoView = new VideoView(this);
setContentView(videoView);

Bundle extra = getIntent().getExtras();
if (null != extra && extra.containsKey("url")) {
    String url = extra.getString("url");
    Uri uri = Uri.parse(url);
    MediaController mc = new MediaController(this);
    videoView.setMediaController(mc);

    videoView.setVideoURI(uri);
    videoView.start();
}

Upvotes: 1

Related Questions