Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I've build the exoplayer ffmpeg extension and added to my project, because i need to support AMR format, so:
Following the tutorial:
FFmpeg Extension
COMMON_OPTIONS="\
--enable-decoder=amrnb \
--enable-decoder=amrwb \
After the compilation step:
cd "${FFMPEG_EXT_PATH}"/jni && \
${NDK_PATH}/ndk-build APP_ABI="armeabi-v7a arm64-v8a x86" -j4
I've generated aar file with:
./gradlew :extensions-ffmpeg:assembleDebug
So I got the extension-ffmpeg-debug.arr file generated and put it in the lib folder of my project.
My player implementation:
public class DefaultPlayer {
private ExoPlayer player;
//"flac" "amr" "wma" "wav" "3gp" "mp3"
public DefaultPlayer(Context context) {
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
playerInit(context, bandwidthMeter);
try {
testFormat(context);
} catch (RawResourceDataSource.RawResourceDataSourceException e) {
e.printStackTrace();
private void testFormat(Context context) throws RawResourceDataSource.RawResourceDataSourceException {
Uri uri = RawResourceDataSource.buildRawResourceUri(R.raw.sample_flac);
final RawResourceDataSource dataSource = new RawResourceDataSource(context);
dataSource.open(new DataSpec(uri));
DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
ExtractorMediaSource mediaSource = new ExtractorMediaSource(uri, new DataSource.Factory() {
@Override
public DataSource createDataSource() {
return dataSource;
}, extractorsFactory, null, null);
player.prepare(mediaSource);
player.setPlayWhenReady(true);
private void playerInit(Context context, DefaultBandwidthMeter bandwidthMeter) {
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
player.addListener(new PlayerEventListener());
The error:
08-04 16:03:53.405 10873-10918/br.com.andersonsilva.musicmodel E/ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor, FlacExtractor) could read the stream.
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractorHolder.selectExtractor(ExtractorMediaPeriod.java:774)
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:697)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
08-04 16:03:53.406 10873-10873/br.com.andersonsilva.musicmodel D/MUSIC: event: PlayerErrorEvent{error=com.google.android.exoplayer2.ExoPlaybackException}
08-04 16:03:53.407 10873-10873/br.com.andersonsilva.musicmodel D/MUSIC: event: PlayerStateChangedEvent{playWhenReady=true, playbackState=1}
What else should be configured to run the AMR format, does anyone have any suggestions?
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.