开发者

Play mp4 Video using <Embed> tag on Android Webview

开发者 https://www.devze.com 2023-04-05 04:34 出处:网络
I want to play mp4 video usingtag on Webview. I have few constraints for not to use HTML5tag. I have looked code to play YouTube video on webview. But YouTube uses .flv format. I have .mp4 开发者_Pyth

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 开发者_Python百科video to play.

Thanks in advance.


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();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消