Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Android: play /raw resource with Exoplayer
val player = ExoPlayerFactory.newSimpleInstance(context, DefaultTrackSelector())
val rawDataSource = RawResourceDataSource(context)
// open the /raw resource file
// create a media source with the raw DataSource
val mediaSource = ExtractorMediaSource.Factory(DataSource.Factory { rawDataSource })
// play immediately if true
player.playWhenReady = true
// setup the player using the source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment