android - 想从 android 中的 Assets 文件夹中播放 mp4 视频

标签 android mp4 assets

我想播放 assets/raw 文件夹中的 mp4 视频。 我可以从我的 SD 卡中成功播放 mp4 视频,但无法从 Assets 文件夹或原始文件夹中获取视频。

最佳答案

正如我所说 here ,如果数据被压缩,您的问题可能来自数据的大小:

Hi guys, If I remember well, I had the same kind of issue when loading stuff from the asset folder but with a database. It seems that the stuff in your asset folder can have 2 stats : compressed or not. If it is compressed, then you are allowed 1 Mo of memory to uncompress it, otherwise you will get this kind of exception. There are several bug reports about that because the documentation is not clear. So if you still want to to use your format, you have to either use an uncompressed version, or give an extension like .mp3 or .png to your file. I know it's a bit crazy but I load a database with a .mp3 extension and it works perfectly fine. This other solution is to package your application with a special option to tell it not to compress certain extension. But then you need to build your app manually and add "zip -0" option. The advantage of an uncompressed assest is that the phase of zip-align before publication of an application will align the data correctly so that when loaded in memory it can be directly mapped.

So, solutions :

  • change the extension of the file to .mp3 or .png and see if it works
  • build your app manually and use the zip-0 option

关于android - 想从 android 中的 Assets 文件夹中播放 mp4 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3536708/

相关文章:

android - 如何在单个.mp4 ffmpeg android中合并多个.mp4文件

android - *有什么*方法可以将 Android/drawable 图形链接到/assets?

Android 左、中、右对齐

javascript - 如何保护html视频文件?

android - 从文件夹内容在eclipse中创建android项目

mp4 - VLC制作的MP4损坏

android - 在android应用程序中逐行读取文本文件

ruby-on-rails - Rails 不会更新某些 Assets 的指纹

java - 清理内存后Android应用程序崩溃

android - 如何为设计支持库的 NavigationView 设置样式?