我试图在我的Android应用程序中使用带flac extension的ExoPlayer库。我遇到了以下问题:
如何摆脱这种情况?
我的连接库:
settings.gradle
include ':app', ':playbacktests', ':testutils', ':library'
include ':extension-flac'
的build.gradle
...
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
//compile 'com.google.android.exoplayer:exoplayer:r2.1.1'
compile project (':library')
compile project (':extension-flac')
testCompile 'junit:junit:4.12'
}
示例代码:
DefaultBandwidthMeter bandwidthMeterAudio1 = new DefaultBandwidthMeter();
DataSource.Factory dataSourceFactoryAudio = new DefaultDataSourceFactory(this.getActivity(),
Util.getUserAgent(this.getActivity(), null), bandwidthMeterAudio1);
ExtractorsFactory extractorsFactoryAudio = new DefaultExtractorsFactory();
if (audioUri != null) { // audioUri - string array with paths of flac audio files
if (audio_name != null){
ArrayAdapter <String> adapter = new ArrayAdapter<String>(getActivity(),
R.layout.row_listview, audio_name);
listViewMusic.setAdapter(adapter);
}
audioSource = new MediaSource[audioUri.length];
for (int i = 0; i < audioUri.length; i++) {
audioSource[i] = new ExtractorMediaSource(Uri.parse(audioUri[i]),
dataSourceFactoryAudio,extractorsFactoryAudio, null, null);
}
ConcatenatingMediaSource concatenatingMediaSourceAudio = new ConcatenatingMediaSource(audioSource);
audioPlayer.prepare(concatenatingMediaSourceAudio);
}