小编Avi*_*ran的帖子

ExoPlayer:Uri:无法加载本地媒体Android

我正在尝试将手机中的媒体播放到ExoPlayer中。我正在从Environment.getExternalStorageDirectory().getAbsoluteFile();

每当我尝试播放媒体时-我都会收到此错误-

源错误com.google.android.exoplayer2.upstream.HttpDataSource $ HttpDataSourceException:无法连接到/storage/emulated/0/Download/big_buck_bunny_720p_1mb.mp4

也,

引起原因:java.net.MalformedURLException:无协议:/storage/emulated/0/Download/big_buck_bunny_720p_1mb.mp4

我在这里经过乌里 MediaSource mediaSource = buildMediaSource(Uri.parse(link));

这种方法正在使用Uri

private MediaSource buildMediaSource(Uri uri) {
    DataSource.Factory dataSourceFactory = new 
DefaultHttpDataSourceFactory("ua", BANDWIDTH_METER);
    DashChunkSource.Factory dashChunkSourceFactory = new 
DefaultDashChunkSource.Factory(dataSourceFactory);
    return new DashMediaSource(uri, dataSourceFactory, 
dashChunkSourceFactory, null, null);
}
Run Code Online (Sandbox Code Playgroud)

这就是我获得链接的方式

arrayList1 = video(Environment.getExternalStorageDirectory().getAbsoluteFile());
protected ArrayList<File> video(File file) {
    File[] filename = file.listFiles();
    ArrayList<File>  arrayList2 = new ArrayList<File>();
    try {
        for (File file1 : filename) {
            if (file1.isDirectory()) {
                arrayList2.addAll(video(file1));
            } else {
                if (file1.getName().endsWith(".mp4")) {
                    arrayList2.add(file1);
                }
            }
        }
    }catch (Exception …
Run Code Online (Sandbox Code Playgroud)

android exoplayer exoplayer2.x

1
推荐指数
1
解决办法
1279
查看次数

标签 统计

android ×1

exoplayer ×1

exoplayer2.x ×1