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
DefaultRenderersFactory
toExoPlayer.Builder
, you can enable using the module by setting theextensionRendererMode
parameter of theDefaultRenderersFactory
constructor toEXTENSION_RENDERER_MODE_ON
. This will useLibflacAudioRenderer
for playback ifMediaCodecAudioRenderer
doesn't support the input format. PassEXTENSION_RENDERER_MODE_PREFER
to giveLibflacAudioRenderer
priority overMediaCodecAudioRenderer
. - If you've subclassed
DefaultRenderersFactory
, add aLibflacAudioRenderer
to the output list inbuildAudioRenderers
. ExoPlayer will use the firstRenderer
in the list that supports the input media format. - If you've implemented your own
RenderersFactory
, return aLibflacAudioRenderer
instance fromcreateRenderers
. ExoPlayer will use the firstRenderer
in the returned array that supports the input media format. - If you're using
ExoPlayer.Builder
, pass aLibflacAudioRenderer
in the array ofRenderer
s. ExoPlayer will use the firstRenderer
in the list that supports the input media format.