从原材料资源文件夹播放的MP4视频原材料、文件夹、资源、视频

2023-09-07 14:00:43 作者:这个世界

我已经看到了一些类似的问题,但到目前为止,我已经无法工作得到任何东西。

I've seen a number of similar questions, but so far I've not been able to get anything working.

我试图播放从RES /原始文件夹中的视频(.MP4),只有获得音频,没有视频。视频很短(约3秒),小(350KB),如果我把视频设备(摩托罗拉Droid)直接,它起着罚款。它还可以播放罚款,如果我修改应用从SD卡,而不是资源文件夹阅读。的行为是在两个仿真器和实际的设备相同。

I'm trying to playback a video (.MP4) from the res/raw folder and only get audio, no video. The video is short (about 3 seconds), small (350KB) and if I put the video on the device (Motorola Droid) directly, it plays fine. It also plays fine if I modify the app to read it from the SD card rather than the resource folder. The behavior is the same on both the emulator and the actual device.

不幸的是,我需要这个视频是一个前奏显示之前,为我的应用程序的主屏幕,所以它必须是包的一部分。此外,对应用程序的要求之一是,该应用程序可脱机使用,所以我不能从网络服务器流。我已经尝试了VideoView,SurfaceView和MediaPlayer的,他们没有工作。

Unfortunately, I need this video to be an intro shown just prior to the main screen for my app, so it has to be part of the package. Additionally, one of the app requirements is that the app is available offline, so I can't stream from a web server. I've tried a VideoView, SurfaceView and MediaPlayer, none of them work.

是否有可能从资源文件夹播放视频?我读过一些关于COM pression可能搞砸了视频了,是不是可以手动DECOM preSS的视频,然后播放它,如果是这样,如何​​将这项工作?这似乎是它应该是pretty的基本操作,我只是失去了一些东西?

Is it possible to playback video from the resource folder? I've read something about compression possibly screwing the video up, is it possible to manually decompress the video and then play it, and if so, how would that work? This seems like it should be a pretty basic operation, am I just missing something?

推荐答案

我有同样的麻烦,想尽一切也同意这应该更容易......和记录。只是固定传递VideoView.setVideoUri字符串与android.resource协议,如here. 第一个选项不为我工作,但第二个作用: 开放的URI = Uri.parse(android.resource:// [包装] /+ R.raw [video_resid]); 希望对你的作品了。

I was having the same trouble, tried everything too, agree it should be easier... and documented. Just fixed by passing VideoView.setVideoUri a string with the android.resource protocol, as described here. The first option doesn't work for me, but the second does: Uri uri = Uri.parse("android.resource://[package]/"+R.raw.[video_resid]); Hopefully works for you too.