在 Android 上使用什么格式播放互联网视频?
我正在尝试使用以下代码将视频加载到 VideoView
和 MediaController
中:
video.setVideoURI(Uri.parse(uri));
mediaController = new MediaController(this);
mediaController.setMediaPlayer(video);
mediaController.setAnchorView(footer);
video.setMediaController(mediaController);
video.requestFocus();
video.start();
如果我使用 .3gp 文件(例如 这个)它播放。但我的 MP4 文件无法播放,只是弹出一个对话框:
抱歉,无法播放该视频
我接受该视频的格式可能不正确,因为我没有将其制作为同事制作的。视频应该采用什么格式?
我通常使用 Handbrake 并且运行 Ubuntu。
当前格式:
视频:
尺寸:1024 x 624
编解码器:H.264 /AVC
帧速率:每秒 30 帧
比特率:1307kbps
音频:
编解码器:MPEG-4 AAC 音频
频道:立体声
采样率:44100 Hz
比特率:63kbps
以下是 LogCat 作为资源播放时出现的一些错误:
12-20 10:54:26.120: I/MediaPlayer(27966): uri is:android.resource://com.android.player/2130968576
12-20 10:54:26.120: I/MediaPlayer(27966): path is null
12-20 10:54:26.160: E/MediaPlayer(27966): Unable to to create media player
12-20 10:54:26.160: D/MediaPlayer(27966): Couldn't open file on client side, trying server side
12-20 10:54:26.160: I/MediaPlayer(27966): prepareAsync called in state 4
12-20 10:54:26.160: E/MediaPlayer(27966): error (1, -2147483648)
12-20 10:54:26.210: E/MediaPlayer(27966): Error (1,-2147483648)
12-20 10:54:26.210: D/VideoView(27966): Error: 1,-2147483648
I'm trying to load a video into a VideoView
and MediaController
with the following code:
video.setVideoURI(Uri.parse(uri));
mediaController = new MediaController(this);
mediaController.setMediaPlayer(video);
mediaController.setAnchorView(footer);
video.setMediaController(mediaController);
video.requestFocus();
video.start();
If I use a .3gp file (such as this) it plays. But my MP4 file won't play just bringing up a dialog box saying:
Sorry, this can't play this video
I accept the video may not be in the correct formats for such a purpose as I didn't make it a colleague did. What format should the videos be in?
I use Handbrake usually and am running Ubuntu.
Format Currently:
Video:
Dimensions: 1024 x 624
CODEC: H.264 /AVC
Framerate: 30 frames per second
bitrate: 1307kbps
Audio:
CODEC: MPEG-4 AAC audio
Channels: Stereo
Sample rate: 44100 Hz
Bitrate: 63kbps
Here are some errors from LogCat when playing it as a resource:
12-20 10:54:26.120: I/MediaPlayer(27966): uri is:android.resource://com.android.player/2130968576
12-20 10:54:26.120: I/MediaPlayer(27966): path is null
12-20 10:54:26.160: E/MediaPlayer(27966): Unable to to create media player
12-20 10:54:26.160: D/MediaPlayer(27966): Couldn't open file on client side, trying server side
12-20 10:54:26.160: I/MediaPlayer(27966): prepareAsync called in state 4
12-20 10:54:26.160: E/MediaPlayer(27966): error (1, -2147483648)
12-20 10:54:26.210: E/MediaPlayer(27966): Error (1,-2147483648)
12-20 10:54:26.210: D/VideoView(27966): Error: 1,-2147483648
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我灵光一现,发现该视频托管在 Amazon S3 上。将其上传到我们的 IIS Web 服务器即可播放!
I had one of those light-bulb moments and discovered that the video was hosted on Amazon S3. Uploaded it to our IIS Web Server and it plays!