简体   繁体   English

如何在Android中播放mp4视频

[英]How to play mp4 video in android

I want to play mp4 video from server in android. 我想从android服务器中播放mp4视频。 Video URL 影片网址

I tried with using video view but there is blank screen appear. 我尝试使用视频视图,但是出现黑屏。 I also tried with Intent.Action view but it show message "Cant play video". 我也尝试了Intent.Action视图,但显示消息“无法播放视频”。

Is there any other way to do this ? 还有其他方法吗?

Thanks in advance. 提前致谢。

Use Like this: 像这样使用:

Uri uri = Uri.parse(URL); //Declare your url here.

VideoView mVideoView  = (VideoView)findViewById(R.id.videoview)
mVideoView.setMediaController(new MediaController(this));       
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();

Another Method: 另一种方法:

String LINK = "type_here_the_link";
  VideoView mVideoView  = (VideoView) findViewById(R.id.videoview);
  MediaController mc = new MediaController(this);
  mc.setAnchorView(videoView);
  mc.setMediaPlayer(videoView);
  Uri video = Uri.parse(LINK);
  mVideoView.setMediaController(mc);
  mVideoView.setVideoURI(video);
  mVideoView.start();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM