Simplifications
This commit is contained in:
parent
0d43cc8658
commit
14ca32a624
|
@ -26,12 +26,7 @@ public class AudioplayerActivity extends MediaplayerInfoActivity {
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (TextUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) {
|
||||
Intent intent = getIntent();
|
||||
if (intent.getData() == null) {
|
||||
return;
|
||||
}
|
||||
playExternalMedia(intent.getData().getPath(), MediaType.AUDIO);
|
||||
|
||||
playExternalMedia(getIntent(), MediaType.AUDIO);
|
||||
} else if (PlaybackService.isCasting()) {
|
||||
Intent intent = PlaybackService.getPlayerActivityIntent(this);
|
||||
if (intent.getComponent() != null &&
|
||||
|
|
|
@ -964,7 +964,10 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
}
|
||||
}
|
||||
|
||||
void playExternalMedia(String path, MediaType type) {
|
||||
void playExternalMedia(Intent intent, MediaType type) {
|
||||
if (intent == null || intent.getData() == null) {
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 23
|
||||
&& ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
|
@ -978,8 +981,8 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
return;
|
||||
}
|
||||
|
||||
Log.d(TAG, "Received VIEW intent: " + path);
|
||||
ExternalMedia media = new ExternalMedia(path, type);
|
||||
Log.d(TAG, "Received VIEW intent: " + intent.getData().getPath());
|
||||
ExternalMedia media = new ExternalMedia(intent.getData().getPath(), type);
|
||||
|
||||
new PlaybackServiceStarter(this, media)
|
||||
.startWhenPrepared(true)
|
||||
|
|
|
@ -77,11 +77,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (TextUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) {
|
||||
Intent intent = getIntent();
|
||||
if (intent.getData() == null) {
|
||||
return;
|
||||
}
|
||||
playExternalMedia(intent.getData().getPath(), MediaType.VIDEO);
|
||||
playExternalMedia(getIntent(), MediaType.VIDEO);
|
||||
} else if (PlaybackService.isCasting()) {
|
||||
Intent intent = PlaybackService.getPlayerActivityIntent(this);
|
||||
if (!intent.getComponent().getClassName().equals(VideoplayerActivity.class.getName())) {
|
||||
|
|
Loading…
Reference in New Issue