A ExoPlayer extension for support flac.
Please refer to AndroidX Media for the usage instructions of the latest release.
ExoPlayer modules can be obtained from the Google Maven repository. It's also possible to clone the repository and depend on the modules locally.
repositories {
mavenCentral()
maven { url 'https://www.jitpack.io' }
}The easiest way to get started using ExoPlayer is to add it as a gradle
dependency in the build.gradle file of your app module. The following will add
a dependency to the full library:
implementation 'com.github.HeHang0:exoplayer-extension-flac:1.3.0'where 1.3.0 is your preferred version.
If not enabled already, you also need to turn on Java 8 support in all
build.gradle files depending on ExoPlayer, by adding the following to the
android section:
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}If your Gradle minSdkVersion is 20 or lower, you should
enable multidex in order
to prevent build errors.
ExoPlayer.Builder builder = ExoPlayer.Builder(context);
DefaultRenderersFactory factory = new DefaultRenderersFactory(context.getApplicationContext())
.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
builder.setRenderersFactory(factory);
ExoPlayer player = builder.build();- If you're passing a
DefaultRenderersFactorytoExoPlayer.Builder, you can enable using the module by setting theextensionRendererModeparameter of theDefaultRenderersFactoryconstructor toEXTENSION_RENDERER_MODE_ON. This will useLibflacAudioRendererfor playback ifMediaCodecAudioRendererdoesn't support the input format. PassEXTENSION_RENDERER_MODE_PREFERto giveLibflacAudioRendererpriority overMediaCodecAudioRenderer. - If you've subclassed
DefaultRenderersFactory, add aLibflacAudioRendererto the output list inbuildAudioRenderers. ExoPlayer will use the firstRendererin the list that supports the input media format. - If you've implemented your own
RenderersFactory, return aLibflacAudioRendererinstance fromcreateRenderers. ExoPlayer will use the firstRendererin the returned array that supports the input media format. - If you're using
ExoPlayer.Builder, pass aLibflacAudioRendererin the array ofRenderers. ExoPlayer will use the firstRendererin the list that supports the input media format.