Lyu*_*eva 12 android exoplayer
我正在尝试使用ExoPlayer而不是MediaPlayer,因为它是MediaPlayer返回错误的getCurrentPosition()的常见错误,我需要替代品.
但是我无法在任何地方找到如何通过文件路径打开本地文件的信息,该文件路径与MediaPlayer相同 .setDataSource(String filepath)
Google没有任何示例,官方文档网站在两台计算机上都奇怪地崩溃了我的FireFox浏览器
小智 9
可以修改github中的ExoPlayer演示应用程序以播放本地文件.为此,请修改https://github.com/google/ExoPlayer/blob/master/demo/src/main/java/com/google/android/exoplayer/demo/Samples.java文件以添加新视频集.
public static final Sample[] LOCAL_VIDEOS = new Sample[] {
new Sample("Some User friendly name of video 1",
"/mnt/sdcard/video1.mp4", DemoUtil.TYPE_OTHER),
new Sample("Some User friendly name of video 2",
"/mnt/sdcard/video2.mp4", DemoUtil.TYPE_OTHER),
};
Run Code Online (Sandbox Code Playgroud)
为此,请编辑https://github.com/google/ExoPlayer/blob/master/demo/src/main/java/com/google/android/exoplayer/demo/Samples.java文件以添加新的示例集.
sampleAdapter.add(new Header("Local Videos"));
sampleAdapter.addAll((Object[]) Samples.LOCAL_VIDEOS);
Run Code Online (Sandbox Code Playgroud)
小智 5
对Srikanth Peddibhotla的代码进行了一些小修改
Samples.java中文件的Uri字符串应为"file:///mnt/sdcard/YourFilename.mp4"而不是"/mnt/sdcard/YourFilename.mp4"
public static final Sample[] LOCAL_VIDEOS = new Sample[] {
new Sample("Some User friendly name of video 1",
"file:///mnt/sdcard/video1.mp4", DemoUtil.TYPE_MP4),
new Sample("Some User friendly name of video 2",
"file:///mnt/sdcard/video2.mp4", DemoUtil.TYPE_MP4),
};
Run Code Online (Sandbox Code Playgroud)
另外,将以下行添加到SampleChooserActivity.java
sampleAdapter.add(new Header("Local Videos"));
sampleAdapter.addAll((Object[]) Samples.LOCAL_VIDEOS);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7961 次 |
| 最近记录: |