ExoPlayer - how to play local mp3 file

前端 未结 4 588
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-07 13:37

I\'m trying to use ExoPlayer instead of MediaPlayer because it\'s a common bug that MediaPlayer returns wrong getCurrentPosition() and I need a substitute.

But I can\'t

4条回答
  •  悲&欢浪女
    2021-02-07 13:53

    A minor modification with Srikanth Peddibhotla's code works

    The Uri string for the file should be "file:///mnt/sdcard/YourFilename.mp4" instead of "/mnt/sdcard/YourFilename.mp4" in Samples.java

    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),
    }; 
    

    Also, add the following lines to SampleChooserActivity.java

     sampleAdapter.add(new Header("Local Videos"));
     sampleAdapter.addAll((Object[]) Samples.LOCAL_VIDEOS);
    

提交回复
热议问题