在 Android 上使用什么格式播放互联网视频?

发布于 2024-12-22 02:04:25 字数 1617 浏览 0 评论 0原文

我正在尝试使用以下代码将视频加载到 VideoViewMediaController 中:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

攒眉千度 2024-12-29 02:04:25

我灵光一现,发现该视频托管在 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文