use of de.danoeh.antennapod.core.service.playback.PlayerStatus in project AntennaPod by AntennaPod.
the class PlayerWidgetService method updateViews.
private void updateViews() {
isUpdating = true;
ComponentName playerWidget = new ComponentName(this, PlayerWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
RemoteViews views = new RemoteViews(getPackageName(), R.layout.player_widget);
PendingIntent startMediaplayer = PendingIntent.getActivity(this, 0, PlaybackService.getPlayerActivityIntent(this), 0);
Intent startApp = new Intent(getBaseContext(), MainActivity.class);
startApp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startApp.putExtra(MainActivity.EXTRA_FRAGMENT_TAG, QueueFragment.TAG);
PendingIntent startAppPending = PendingIntent.getActivity(getBaseContext(), 0, startApp, PendingIntent.FLAG_UPDATE_CURRENT);
boolean nothingPlaying = false;
if (playbackService != null) {
final Playable media = playbackService.getPlayable();
if (media != null) {
PlayerStatus status = playbackService.getStatus();
views.setOnClickPendingIntent(R.id.layout_left, startMediaplayer);
views.setTextViewText(R.id.txtvTitle, media.getEpisodeTitle());
String progressString = getProgressString();
if (progressString != null) {
views.setViewVisibility(R.id.txtvProgress, View.VISIBLE);
views.setTextViewText(R.id.txtvProgress, progressString);
}
if (status == PlayerStatus.PLAYING) {
views.setImageViewResource(R.id.butPlay, R.drawable.ic_pause_white_24dp);
if (Build.VERSION.SDK_INT >= 15) {
views.setContentDescription(R.id.butPlay, getString(R.string.pause_label));
}
} else {
views.setImageViewResource(R.id.butPlay, R.drawable.ic_play_arrow_white_24dp);
if (Build.VERSION.SDK_INT >= 15) {
views.setContentDescription(R.id.butPlay, getString(R.string.play_label));
}
}
views.setOnClickPendingIntent(R.id.butPlay, createMediaButtonIntent());
} else {
nothingPlaying = true;
}
} else {
nothingPlaying = true;
}
if (nothingPlaying) {
// start the app if they click anything
views.setOnClickPendingIntent(R.id.layout_left, startAppPending);
views.setOnClickPendingIntent(R.id.butPlay, startAppPending);
views.setViewVisibility(R.id.txtvProgress, View.INVISIBLE);
views.setTextViewText(R.id.txtvTitle, this.getString(R.string.no_media_playing_label));
views.setImageViewResource(R.id.butPlay, R.drawable.ic_play_arrow_white_24dp);
}
manager.updateAppWidget(playerWidget, views);
isUpdating = false;
}
use of de.danoeh.antennapod.core.service.playback.PlayerStatus in project AntennaPod by AntennaPod.
the class PlaybackSonicTest method testContinousPlaybackOffMultipleEpisodes.
@FlakyTest(tolerance = 3)
public void testContinousPlaybackOffMultipleEpisodes() throws Exception {
setContinuousPlaybackPreference(false);
uiTestUtils.addLocalFeedData(true);
List<FeedItem> queue = DBReader.getQueue();
final FeedItem first = queue.get(0);
startLocalPlaybackFromQueue();
boolean stopped = solo.waitForCondition(() -> {
if (uiTestUtils.getPlaybackController(getActivity()).getStatus() != PlayerStatus.PLAYING) {
return true;
} else if (uiTestUtils.getCurrentMedia(getActivity()) != null) {
return uiTestUtils.getCurrentMedia(getActivity()).getId() != first.getMedia().getId();
} else {
return true;
}
}, Timeout.getSmallTimeout());
assertTrue(stopped);
Thread.sleep(1000);
PlayerStatus status = uiTestUtils.getPlaybackController(getActivity()).getStatus();
assertFalse(status.equals(PlayerStatus.PLAYING));
}
use of de.danoeh.antennapod.core.service.playback.PlayerStatus in project AntennaPod by AntennaPod.
the class PlaybackTest method testContinousPlaybackOffMultipleEpisodes.
@FlakyTest(tolerance = 3)
public void testContinousPlaybackOffMultipleEpisodes() throws Exception {
setContinuousPlaybackPreference(false);
uiTestUtils.addLocalFeedData(true);
List<FeedItem> queue = DBReader.getQueue();
final FeedItem first = queue.get(0);
startLocalPlaybackFromQueue();
boolean stopped = solo.waitForCondition(() -> {
if (uiTestUtils.getPlaybackController(getActivity()).getStatus() != PlayerStatus.PLAYING) {
return true;
} else if (uiTestUtils.getCurrentMedia(getActivity()) != null) {
return uiTestUtils.getCurrentMedia(getActivity()).getId() != first.getMedia().getId();
} else {
return true;
}
}, Timeout.getSmallTimeout());
assertTrue(stopped);
Thread.sleep(1000);
PlayerStatus status = uiTestUtils.getPlaybackController(getActivity()).getStatus();
assertFalse(status.equals(PlayerStatus.PLAYING));
}
Aggregations