在Android

时间:2017-01-17 17:41:43

标签: java android exoplayer flac

我试图在我的Android应用程序中使用带flac extension的ExoPlayer库。我遇到了以下问题:

  • 并非所有文件都可以播放(据我了解高比特率文件的问题);
  • 并非所有能够以flac格式播放音频文件的设备(在模拟器和三星Galaxy S5上播放,但在Sony Xperia XA上播放 - 类似于白噪声而非音频。所有设备都安装了Android 6.0。我尝试过使用版本1.3.1和1.3.2编译flac扩展名

如何摆脱这种情况?

我的连接库:

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);
    }

0 个答案:

没有答案