parohy
parohy

Reputation: 2180

ExoPlayer not playing from file

I have a ExoPlayer set up with HlsRendererBuilder. So far I have been passing it an Uri to a m3u8 stream file on the server. It is working great. Now I have an option to download the video to your phone and play it from storage. I have successfully downloaded the file from the given link, stored it in the app private folder. All permissions to access external storage requested and approved. In this case I am passing an Uri from file which I have downloaded. Uri looks like this: file:///storage/emulated/0/video/file.mp4. When I start the playback the file is never loaded. I do not get any exception or error in the log. Can anyone help me to suggest an approach? I will provide snippet of codes if needed, but not sure which part would be useful.

I have ExoPlayer.Listener which logs me of the player state.

  1. When I am streaming I get various states starting from IDLE -> BUFFERING -> READY -> BUFFERING ... so on based on the internet connection or if the media ended ec.
  2. When I am playing stored file I only get state IDLE and nothing else happens. I got black screen forever until I finish() the activity.

When I tried to play stream file from local storage I did got an FileNotFound exception that it cannot find the file, next part of media listed in the stream file. I assume the problem would be in the player setup? Not sure...

Upvotes: 2

Views: 3460

Answers (2)

Bartek Lipinski
Bartek Lipinski

Reputation: 31438

You need to use a different RendererBuilder for a local (video/audio) file.

ExtractorRendererBuilder is the thing you should be looking at.

Upvotes: 3

Lucas Santos
Lucas Santos

Reputation: 170

As you're using HlsRendererBuilder I think you should pass the .m3u8 playlist file. I'm basing on my experience with DashRendererBuilder but I believe HlsRendererBuilder works in a very similar way. The Renderer probably is trying to parse a playlist with multiple .mp4 (or .ts) files but you are providing just a .mp4file.

Try to download all files listed in your .m3u8file including your playlist file and then pass the URI like file:///storage/emulated/0/video/movie.m3u8 to your renderer.

Hope it helps!

Upvotes: 1

Related Questions