Enable cross-protocol redirects in ExoPlayer (#55)
This commit is contained in:
parent
05504374ca
commit
8d15a6c65c
|
@ -12,6 +12,8 @@ import com.google.android.exoplayer2.source.dash.DashMediaSource;
|
||||||
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
|
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||||
|
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
|
||||||
|
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import io.flutter.plugin.common.EventChannel;
|
import io.flutter.plugin.common.EventChannel;
|
||||||
import io.flutter.plugin.common.EventChannel.EventSink;
|
import io.flutter.plugin.common.EventChannel.EventSink;
|
||||||
|
@ -250,7 +252,14 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener {
|
||||||
abortExistingConnection();
|
abortExistingConnection();
|
||||||
prepareResult = result;
|
prepareResult = result;
|
||||||
transition(PlaybackState.connecting);
|
transition(PlaybackState.connecting);
|
||||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context, "just_audio"));
|
String userAgent = Util.getUserAgent(context, "just_audio");
|
||||||
|
DataSource.Factory httpDataSourceFactory = new DefaultHttpDataSourceFactory(
|
||||||
|
userAgent,
|
||||||
|
DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
|
||||||
|
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, httpDataSourceFactory);
|
||||||
Uri uri = Uri.parse(url);
|
Uri uri = Uri.parse(url);
|
||||||
if (uri.getPath().toLowerCase().endsWith(".mpd")) {
|
if (uri.getPath().toLowerCase().endsWith(".mpd")) {
|
||||||
mediaSource = new DashMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
|
mediaSource = new DashMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
|
||||||
|
|
Loading…
Reference in New Issue