Bigger buffer
This commit is contained in:
parent
ae319b9689
commit
0ef1be2084
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.DefaultLoadControl;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
@ -472,8 +473,9 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Aud
|
||||
uri = Uri.parse(((String)map.get("uri")).replace("#" + fragment, ""));
|
||||
return new ProgressiveMediaSource.Factory(
|
||||
() -> {
|
||||
HttpDataSource deezerDataSource = new DeezerDataSource(fragment);
|
||||
return deezerDataSource;
|
||||
return new DeezerDataSource(fragment);
|
||||
// HttpDataSource deezerDataSource = new DeezerDataSource(fragment);
|
||||
// return deezerDataSource;
|
||||
}
|
||||
).setTag(id).createMediaSource(uri);
|
||||
}
|
||||
@ -565,7 +567,11 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Aud
|
||||
|
||||
private void ensurePlayerInitialized() {
|
||||
if (player == null) {
|
||||
player = new SimpleExoPlayer.Builder(context).build();
|
||||
//Load buffer
|
||||
DefaultLoadControl.Builder loadControlBuilder = new DefaultLoadControl.Builder();
|
||||
loadControlBuilder.setBufferDurationsMs(12500, 200000, 2500, 6000);
|
||||
|
||||
player = new SimpleExoPlayer.Builder(context).setLoadControl(loadControlBuilder.createDefaultLoadControl()).build();
|
||||
player.addMetadataOutput(this);
|
||||
player.addListener(this);
|
||||
player.addAudioListener(this);
|
||||
@ -595,11 +601,21 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Aud
|
||||
|
||||
|
||||
String qualityString = "";
|
||||
if (player != null && player.getAudioFormat() != null && player.getAudioFormat().sampleMimeType != null) {
|
||||
if (player.getAudioFormat().sampleMimeType.equals("audio/mpeg")) {
|
||||
qualityString = "MP3";
|
||||
if (player != null && player.getAudioFormat() != null) {
|
||||
if (player.getAudioFormat().sampleMimeType != null) {
|
||||
if (player.getAudioFormat().sampleMimeType.equals("audio/mpeg")) {
|
||||
qualityString = "MP3";
|
||||
} else {
|
||||
qualityString = "FLAC";
|
||||
}
|
||||
} else {
|
||||
qualityString = "FLAC";
|
||||
if (player.getAudioFormat().containerMimeType != null) {
|
||||
if (player.getAudioFormat().containerMimeType.equals("audio/mpeg")) {
|
||||
qualityString = "MP3";
|
||||
} else {
|
||||
qualityString = "FLAC";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
event.put("qualityString", qualityString);
|
||||
|
Loading…
Reference in New Issue
Block a user