Open distinctdan opened 9 months ago
Thanks for reporting!
That's what I think could be helpful from the existing docs:
[1] The simplest approach is using a MediaItem
which is documented here.
[2] When using a MediaItem
, a media source is created for it internally. More about this and MediaSources
can be found here.
[3] The specific media source implementation for profgressive media is documented here and in the JavaDoc you are referring to.
I agree that the last page [3] is hard to find. It took me some attempts to find it when googling. Without including Media3
the page didn't show up.
I mark as documentation so we create the linking and can see that 'ExoPlayer' is somehow working similarly than 'Media3' when searching the ExoPlayer developer guide.
Update: I wasn't able to get ProgressiveMediaSource to work at all, it kept giving me "file not found" errors. But, I was able to use a media item directly to play my local file. Again, this took an entire afternoon of googling to find a working solution, I think the docs need to be updated to include this common use case. Here's my solution from this old stack overflow post:
val uri = RawResourceDataSource.buildRawResourceUri(R.raw.my_video)
val mediaItem = MediaItem.fromUri(uri)
player.setMediaItem(mediaItem)
https://stackoverflow.com/questions/40276012/how-to-get-local-video-uri-for-exoplayer-2-x
I had originally tried to use ProgressiveMediaSource since I thought you were supposed to create a media source for the player. Here's my non-working code, again, I was guessing here because I haven't found any usage docs:
// Throws "androidx.media3.datasource.FileDataSource$FileDataSourceException: java.io.FileNotFoundException: /2131886084: open failed: ENOENT (No such file or directory)"
val mediaSource = ProgressiveMediaSource.Factory(
FileDataSource.Factory()
).createMediaSource(mediaItem)
Version
Media3 1.2.1
More version details
No response
Devices that reproduce the issue
N/A
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
I'm trying to use ProgressiveMediaSource to play a local .mp4 video file using ExoPlayer. However, I've spent an hour browsing docs, and I can't find any documentation on how this thing is supposed to work. I would expect an example to be present in
ProgressiveMediaSource
orProgressiveMediaSource.Factory
, located here: https://developer.android.com/reference/androidx/media3/exoplayer/source/ProgressiveMediaSource. This is a common use case that with MediaPlayer was as simple as passing it a URI. I know ExoPlayer supports it too, but it's not obvious how to do it, so I think this is a docs bug that there isn't any documentation on how to do it.Expected result
N/A
Actual result
N/A
Media
N/A
Bug Report
adb bugreport
to android-media-github@google.com after filing this issue.