made the local player respect the auto play setting
...also some minor refactoring
This commit is contained in:
parent
14e1abc28e
commit
685491a674
2 changed files with 18 additions and 7 deletions
|
@ -40,14 +40,14 @@ public class LocalPlayerActivity extends AppCompatActivity implements Player.Eve
|
|||
|
||||
final Intent intent = getIntent();
|
||||
|
||||
final String uri = intent.getDataString();
|
||||
final VideoSegment[] segments = getSegmentsFromIntent(intent);
|
||||
final String uri = parseUriFromIntent(intent);
|
||||
final VideoSegment[] segments = parseSegmentsFromIntent(intent);
|
||||
|
||||
localPlayer = new LocalPlayer(this);
|
||||
localPlayer.initPlayer(uri, segments);
|
||||
localPlayer.initialize(uri, segments);
|
||||
|
||||
final PlayerView playerView = findViewById(R.id.player_view);
|
||||
playerView.setPlayer(localPlayer.getPlayer());
|
||||
playerView.setPlayer(localPlayer.getExoPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,7 +93,11 @@ public class LocalPlayerActivity extends AppCompatActivity implements Player.Eve
|
|||
setKeepScreenOn(false);
|
||||
}
|
||||
|
||||
private static VideoSegment[] getSegmentsFromIntent(final Intent intent) {
|
||||
private static String parseUriFromIntent(final Intent intent) {
|
||||
return intent.getDataString();
|
||||
}
|
||||
|
||||
private static VideoSegment[] parseSegmentsFromIntent(final Intent intent) {
|
||||
final List<VideoSegment> result = new ArrayList<>();
|
||||
|
||||
final String segmentsJson = intent.getStringExtra("segments");
|
||||
|
|
|
@ -51,7 +51,7 @@ public class LocalPlayer implements EventListener {
|
|||
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(App.getApp());
|
||||
}
|
||||
|
||||
public void initPlayer(final String uri, final VideoSegment[] segments) {
|
||||
public void initialize(final String uri, final VideoSegment[] segments) {
|
||||
this.videoSegments = segments;
|
||||
this.progressUpdateReactor = new SerialDisposable();
|
||||
|
||||
|
@ -62,6 +62,13 @@ public class LocalPlayer implements EventListener {
|
|||
simpleExoPlayer.setSeekParameters(PlayerHelper.getSeekParameters(context));
|
||||
simpleExoPlayer.setHandleAudioBecomingNoisy(true);
|
||||
|
||||
final String autoPlayStr =
|
||||
mPrefs.getString(context.getString(R.string.autoplay_key), "");
|
||||
final boolean autoPlay =
|
||||
!autoPlayStr.equals(context.getString(R.string.autoplay_never_key));
|
||||
|
||||
simpleExoPlayer.setPlayWhenReady(autoPlay);
|
||||
|
||||
if (uri == null || uri.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -72,7 +79,7 @@ public class LocalPlayer implements EventListener {
|
|||
simpleExoPlayer.prepare(videoSource);
|
||||
}
|
||||
|
||||
public SimpleExoPlayer getPlayer() {
|
||||
public SimpleExoPlayer getExoPlayer() {
|
||||
return this.simpleExoPlayer;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue