在 Android 中播放 RAM 中的视频
Playing Video from RAM in Android
我在 RAM 中加载了视频文件,并想让 MediaPlayer 使用 RAM 中的信息来播放视频。我在 Windows 中通过直接使用 VLC 的 API 完成了此操作。但我不确定是否可以在 Android 中使用它。 MediaPlayer 接受文件或 Internet 流作为输入,但没有记录支持 RAM。有人试过这个吗?
将视频加载到 RAM 上不是一个好主意。有许多设备的 RAM 量非常低。始终使用临时文件夹来满足此类需求,如果不想保留它,请在退出应用程序时将其清除。
这是创建临时文件的方法。
File outputDir = context.getCacheDir(); // Gets the cache dir, which is a temp directory.
File outputFile = File.createTempFile("video", "mp4", outputDir);
然后用android媒体播放器打开。
我在 RAM 中加载了视频文件,并想让 MediaPlayer 使用 RAM 中的信息来播放视频。我在 Windows 中通过直接使用 VLC 的 API 完成了此操作。但我不确定是否可以在 Android 中使用它。 MediaPlayer 接受文件或 Internet 流作为输入,但没有记录支持 RAM。有人试过这个吗?
将视频加载到 RAM 上不是一个好主意。有许多设备的 RAM 量非常低。始终使用临时文件夹来满足此类需求,如果不想保留它,请在退出应用程序时将其清除。
这是创建临时文件的方法。
File outputDir = context.getCacheDir(); // Gets the cache dir, which is a temp directory.
File outputFile = File.createTempFile("video", "mp4", outputDir);
然后用android媒体播放器打开。