我最近将应用音频文件资源切换为扩展文件。问题是,当我使用APEZProvider读取音频文件时,应用程序不会播放任何内容。
请参阅Exoplayer错误:
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) could read the stream.
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractorHolder.selectExtractor(ExtractorMediaPeriod.java:705)
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:628)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:295)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
E/MMParserExtractor: FileSource::FILE_SOURCE_DATA_EN
我的自定义APEZProvider:
public class ZipFileContentProvider extends APEZProvider {
String AUTHORITY = "sample.sample";
@Override
public String getAuthority() {
return AUTHORITY;
}
public Uri readAudioFileFromObb(String filename){
String path = "content://" + AUTHORITY + File.separator + filename;
return Uri.parse(path);
}
}
我的AndroidManifest.xml
<provider
android:authorities="sample.sample"
android:name=".PlaySong.ZipFileContentProvider"
android:exported="true"
android:multiprocess="true">
<meta-data
android:name="mainVersion"
android:value="14"></meta-data>
</provider>
Exoplayer版本='r2.2.0'
答案 0 :(得分:0)
我怀疑您需要在getType()
中覆盖APEZContentProvider
方法以返回相应的音频类型。