android - 如何通过服务器在 Android 中播放 mp4 视频

标签 android android-videoview

我正在使用以下代码播放存储在服务器中的 mp4 视频....我收到这样的错误->

这个视频无法播放????


Uri video = Uri.parse("http://129.0.0.....");

MediaController mediaController = null;
mVideoView.setMediaController(mediaController);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://129.0.0....")));
mVideoView.setVideoURI(video);
mVideoView.setVideoPath("http://129.0.0......");
mVideoView.requestFocus();
mVideoView.start();

最佳答案

这可能对你有帮助,我在 android 2.3.3 中使用过它。

public void videoPlayer(String path, String fileName, boolean autoplay){
//get current window information, and set format, set it up differently, if you need some special effects
getWindow().setFormat(PixelFormat.TRANSLUCENT);
//the VideoView will hold the video
VideoView videoHolder = new VideoView(this);
//MediaController is the ui control howering above the video (just like in the default youtube player).
videoHolder.setMediaController(new MediaController(this));
//assing a video file to the video holder
videoHolder.setVideoURI(Uri.parse(YOUR_SERVER_VIDEOFILE_URL));
//get focus, before playing the video.
videoHolder.requestFocus();
if(autoplay){
    videoHolder.start();
}

}

关于android - 如何通过服务器在 Android 中播放 mp4 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9614693/

相关文章:

android - Paho MQTT 客户端在设备锁定后断开连接

java - 当TAB 1的RecyclerView中添加数据时更新TAB 2 Recyclerview

android - 使用 ffmpeg 和 ffserver 通过 rtsp 将网络摄像头提要流式传输到 android 客户端

Android 检查视频流结束

android - 将 VideoView 与基本的经过身份验证的 URL 一起使用

java - 选择要使用哪个 fragment 的 Android (Java) Activity

android - 如何使用 Intent 停止android中的 Activity ?

android - 在 SL4a 中使用 Python 读取 GPS 值不起作用

Android VideoView 无法播放视频错误尤其是.mp4