added notification extra to reload notification to switch between
mediaplayers when the media type changes
This commit is contained in:
parent
f25c1f80ec
commit
be7ff097b9
|
@ -5,6 +5,7 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
@ -13,11 +14,13 @@ import android.widget.TextView;
|
|||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
import com.viewpagerindicator.TabPageIndicator;
|
||||
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.SCListAdapter;
|
||||
import de.danoeh.antennapod.feed.SimpleChapter;
|
||||
import de.danoeh.antennapod.fragment.CoverFragment;
|
||||
import de.danoeh.antennapod.fragment.ItemDescriptionFragment;
|
||||
import de.danoeh.antennapod.service.PlaybackService;
|
||||
|
||||
public class AudioplayerActivity extends MediaplayerActivity {
|
||||
|
||||
|
@ -79,8 +82,6 @@ public class AudioplayerActivity extends MediaplayerActivity {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class MediaPlayerPagerAdapter extends
|
||||
FragmentStatePagerAdapter {
|
||||
private int numItems;
|
||||
|
@ -174,6 +175,15 @@ public class AudioplayerActivity extends MediaplayerActivity {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReloadNotification(int notificationCode) {
|
||||
if (notificationCode == PlaybackService.EXTRA_CODE_VIDEO) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG,
|
||||
"ReloadNotification received, switching to Videoplayer now");
|
||||
startActivity(new Intent(this, VideoplayerActivity.class));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -121,6 +121,13 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity {
|
|||
handleStatus();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to switch to another player activity if the mime type is
|
||||
* not the correct one for the current activity.
|
||||
*/
|
||||
protected abstract void onReloadNotification(int notificationCode);
|
||||
|
||||
protected BroadcastReceiver notificationReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
|
@ -147,6 +154,8 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity {
|
|||
positionObserver = null;
|
||||
}
|
||||
mediaInfoLoaded = false;
|
||||
onReloadNotification(intent.getIntExtra(
|
||||
PlaybackService.EXTRA_NOTIFICATION_CODE, -1));
|
||||
queryService();
|
||||
|
||||
break;
|
||||
|
|
|
@ -5,6 +5,7 @@ import de.danoeh.antennapod.R;
|
|||
import de.danoeh.antennapod.service.PlaybackService;
|
||||
import de.danoeh.antennapod.service.PlayerStatus;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
@ -194,4 +195,12 @@ public class VideoplayerActivity extends MediaplayerActivity implements
|
|||
videoSurfaceCreated = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReloadNotification(int notificationCode) {
|
||||
if (notificationCode == PlaybackService.EXTRA_CODE_AUDIO) {
|
||||
if (AppConfig.DEBUG) Log.d(TAG, "ReloadNotification received, switching to Audioplayer now");
|
||||
startActivity(new Intent(this, AudioplayerActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,10 @@ public class PlaybackService extends Service {
|
|||
public static final String EXTRA_NOTIFICATION_CODE = "extra.de.danoeh.antennapod.service.notificationCode";
|
||||
public static final String EXTRA_NOTIFICATION_TYPE = "extra.de.danoeh.antennapod.service.notificationType";
|
||||
|
||||
/** Used in NOTIFICATION_TYPE_RELOAD. */
|
||||
public static final int EXTRA_CODE_AUDIO = 1;
|
||||
public static final int EXTRA_CODE_VIDEO = 2;
|
||||
|
||||
public static final int NOTIFICATION_TYPE_ERROR = 0;
|
||||
public static final int NOTIFICATION_TYPE_INFO = 1;
|
||||
public static final int NOTIFICATION_TYPE_BUFFER_UPDATE = 2;
|
||||
|
@ -478,8 +482,14 @@ public class PlaybackService extends Service {
|
|||
media = nextItem.getMedia();
|
||||
feed = nextItem.getFeed();
|
||||
shouldStream = !media.isDownloaded();
|
||||
int notificationCode = 0;
|
||||
if (media.getMime_type().startsWith("audio")) {
|
||||
notificationCode = EXTRA_CODE_AUDIO;
|
||||
} else if (media.getMime_type().startsWith("video")) {
|
||||
notificationCode = EXTRA_CODE_VIDEO;
|
||||
}
|
||||
resetVideoSurface();
|
||||
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0);
|
||||
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, notificationCode);
|
||||
} else {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Stopping playback");
|
||||
|
|
Loading…
Reference in New Issue