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.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
|
import com.google.android.exoplayer2.DefaultLoadControl;
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.PlaybackParameters;
|
import com.google.android.exoplayer2.PlaybackParameters;
|
||||||
import com.google.android.exoplayer2.Player;
|
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, ""));
|
uri = Uri.parse(((String)map.get("uri")).replace("#" + fragment, ""));
|
||||||
return new ProgressiveMediaSource.Factory(
|
return new ProgressiveMediaSource.Factory(
|
||||||
() -> {
|
() -> {
|
||||||
HttpDataSource deezerDataSource = new DeezerDataSource(fragment);
|
return new DeezerDataSource(fragment);
|
||||||
return deezerDataSource;
|
// HttpDataSource deezerDataSource = new DeezerDataSource(fragment);
|
||||||
|
// return deezerDataSource;
|
||||||
}
|
}
|
||||||
).setTag(id).createMediaSource(uri);
|
).setTag(id).createMediaSource(uri);
|
||||||
}
|
}
|
||||||
@ -565,7 +567,11 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Aud
|
|||||||
|
|
||||||
private void ensurePlayerInitialized() {
|
private void ensurePlayerInitialized() {
|
||||||
if (player == null) {
|
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.addMetadataOutput(this);
|
||||||
player.addListener(this);
|
player.addListener(this);
|
||||||
player.addAudioListener(this);
|
player.addAudioListener(this);
|
||||||
@ -595,12 +601,22 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Aud
|
|||||||
|
|
||||||
|
|
||||||
String qualityString = "";
|
String qualityString = "";
|
||||||
if (player != null && player.getAudioFormat() != null && player.getAudioFormat().sampleMimeType != null) {
|
if (player != null && player.getAudioFormat() != null) {
|
||||||
|
if (player.getAudioFormat().sampleMimeType != null) {
|
||||||
if (player.getAudioFormat().sampleMimeType.equals("audio/mpeg")) {
|
if (player.getAudioFormat().sampleMimeType.equals("audio/mpeg")) {
|
||||||
qualityString = "MP3";
|
qualityString = "MP3";
|
||||||
} else {
|
} else {
|
||||||
qualityString = "FLAC";
|
qualityString = "FLAC";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (player.getAudioFormat().containerMimeType != null) {
|
||||||
|
if (player.getAudioFormat().containerMimeType.equals("audio/mpeg")) {
|
||||||
|
qualityString = "MP3";
|
||||||
|
} else {
|
||||||
|
qualityString = "FLAC";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
event.put("qualityString", qualityString);
|
event.put("qualityString", qualityString);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user