ExoPlayer - play local mp4 file in SD card

后端 未结 8 515
囚心锁ツ
囚心锁ツ 2021-02-04 03:49

I am using the Exoplayer Demo app and want to preload a MP4 video from SD card. I have tried out the implementation from this post, but it does not work. There is no such class

8条回答
  •  -上瘾入骨i
    2021-02-04 04:27

    For those who want to play a video from assets using ExoPlayer 2 here is a way:

    String playerInfo = Util.getUserAgent(context, "ExoPlayerInfo");
    DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(
            context, playerInfo
    );
    MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory)
        .setExtractorsFactory(new DefaultExtractorsFactory())
        .createMediaSource(Uri.parse("asset:///your_video.mov"));
    player.prepare(mediaSource);
    

提交回复
热议问题