switching between media player activities
This commit is contained in:
parent
9d4969b0a7
commit
a77c77724b
|
@ -1,9 +1,11 @@
|
||||||
package de.danoeh.antennapod.activity;
|
package de.danoeh.antennapod.activity;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.cast.CastManager;
|
||||||
import de.danoeh.antennapod.core.feed.MediaType;
|
import de.danoeh.antennapod.core.feed.MediaType;
|
||||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||||
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
||||||
|
@ -14,6 +16,17 @@ import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
||||||
public class AudioplayerActivity extends MediaplayerInfoActivity {
|
public class AudioplayerActivity extends MediaplayerInfoActivity {
|
||||||
public static final String TAG = "AudioPlayerActivity";
|
public static final String TAG = "AudioPlayerActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
if (CastManager.getInstance().isConnected()) {
|
||||||
|
Intent intent = PlaybackService.getPlayerActivityIntent(this);
|
||||||
|
if (!intent.getComponent().getClassName().equals(AudioplayerActivity.class.getName())) {
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -32,4 +45,16 @@ public class AudioplayerActivity extends MediaplayerInfoActivity {
|
||||||
startService(launchIntent);
|
startService(launchIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onReloadNotification(int notificationCode) {
|
||||||
|
if (notificationCode == PlaybackService.EXTRA_CODE_CAST) {
|
||||||
|
Log.d(TAG, "ReloadNotification received, switching to Castplayer now");
|
||||||
|
finish();
|
||||||
|
startActivity(new Intent(this, CastplayerActivity.class));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
super.onReloadNotification(notificationCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,37 @@
|
||||||
package de.danoeh.antennapod.activity;
|
package de.danoeh.antennapod.activity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.cast.CastManager;
|
||||||
|
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by domingos on 4/16/16.
|
* Activity for controlling the remote playback on a Cast device.
|
||||||
*/
|
*/
|
||||||
public class CastplayerActivity extends MediaplayerInfoActivity {
|
public class CastplayerActivity extends MediaplayerInfoActivity {
|
||||||
public static final String TAG = "CastPlayerActivity";
|
public static final String TAG = "CastPlayerActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
if (!CastManager.getInstance().isConnected()) {
|
||||||
|
Intent intent = PlaybackService.getPlayerActivityIntent(this);
|
||||||
|
if (!intent.getComponent().getClassName().equals(CastplayerActivity.class.getName())) {
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onReloadNotification(int notificationCode) {
|
||||||
|
if (notificationCode == PlaybackService.EXTRA_CODE_AUDIO) {
|
||||||
|
Log.d(TAG, "ReloadNotification received, switching to Audioplayer now");
|
||||||
|
finish();
|
||||||
|
startActivity(new Intent(this, AudioplayerActivity.class));
|
||||||
|
} else {
|
||||||
|
super.onReloadNotification(notificationCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.lang.ref.WeakReference;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
|
import de.danoeh.antennapod.core.cast.CastManager;
|
||||||
import de.danoeh.antennapod.core.feed.MediaType;
|
import de.danoeh.antennapod.core.feed.MediaType;
|
||||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||||
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
||||||
|
@ -64,6 +65,12 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY); // has to be called before setting layout content
|
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY); // has to be called before setting layout content
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0x80000000));
|
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0x80000000));
|
||||||
|
if (CastManager.getInstance().isConnected()) {
|
||||||
|
Intent intent = PlaybackService.getPlayerActivityIntent(this);
|
||||||
|
if (!intent.getComponent().getClassName().equals(VideoplayerActivity.class.getName())) {
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,6 +264,10 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
Log.d(TAG, "ReloadNotification received, switching to Audioplayer now");
|
Log.d(TAG, "ReloadNotification received, switching to Audioplayer now");
|
||||||
finish();
|
finish();
|
||||||
startActivity(new Intent(this, AudioplayerActivity.class));
|
startActivity(new Intent(this, AudioplayerActivity.class));
|
||||||
|
} else if (notificationCode == PlaybackService.EXTRA_CODE_CAST) {
|
||||||
|
Log.d(TAG, "ReloadNotification received, switching to Castplayer now");
|
||||||
|
finish();
|
||||||
|
startActivity(new Intent(this, CastplayerActivity.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue