use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class PlaybackVolumeUpdaterTest method updatesPreferencesAndForcesVolumeChangeForLoadedFeedMediaIfPlayerStatusIsPlaying.
@Test
public void updatesPreferencesAndForcesVolumeChangeForLoadedFeedMediaIfPlayerStatusIsPlaying() {
PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.PLAYING);
FeedMedia feedMedia = mockFeedMedia();
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
FeedPreferences feedPreferences = feedMedia.getItem().getFeed().getPreferences();
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.HEAVY_REDUCTION);
verify(feedPreferences, times(1)).setVolumeAdaptionSetting(VolumeAdaptionSetting.HEAVY_REDUCTION);
verify(mediaPlayer, times(1)).pause(false, false);
verify(mediaPlayer, times(1)).resume();
}
use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class RemoteMedia method equals.
@Override
public boolean equals(Object other) {
if (other instanceof RemoteMedia) {
RemoteMedia rm = (RemoteMedia) other;
return TextUtils.equals(downloadUrl, rm.downloadUrl) && TextUtils.equals(feedUrl, rm.feedUrl) && TextUtils.equals(itemIdentifier, rm.itemIdentifier);
}
if (other instanceof FeedMedia) {
FeedMedia fm = (FeedMedia) other;
if (!TextUtils.equals(downloadUrl, fm.getStreamUrl())) {
return false;
}
FeedItem fi = fm.getItem();
if (fi == null || !TextUtils.equals(itemIdentifier, fi.getItemIdentifier())) {
return false;
}
Feed feed = fi.getFeed();
return feed != null && TextUtils.equals(feedUrl, feed.getDownload_url());
}
return false;
}
use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class FeedItemPermutorsTest method getTestList.
/**
* Generates a list with test data.
*/
private List<FeedItem> getTestList() {
List<FeedItem> itemList = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
// January 1st
calendar.set(2019, 0, 1);
Feed feed1 = new Feed(null, null, "Feed title 1");
FeedItem feedItem1 = new FeedItem(1, "Title 1", null, null, calendar.getTime(), 0, feed1);
FeedMedia feedMedia1 = new FeedMedia(0, feedItem1, 1000, 0, 0, null, null, null, true, null, 0, 0);
feedItem1.setMedia(feedMedia1);
itemList.add(feedItem1);
// March 1st
calendar.set(2019, 2, 1);
Feed feed2 = new Feed(null, null, "Feed title 3");
FeedItem feedItem2 = new FeedItem(3, "Title 3", null, null, calendar.getTime(), 0, feed2);
FeedMedia feedMedia2 = new FeedMedia(0, feedItem2, 3000, 0, 0, null, null, null, true, null, 0, 0);
feedItem2.setMedia(feedMedia2);
itemList.add(feedItem2);
// February 1st
calendar.set(2019, 1, 1);
Feed feed3 = new Feed(null, null, "Feed title 2");
FeedItem feedItem3 = new FeedItem(2, "Title 2", null, null, calendar.getTime(), 0, feed3);
FeedMedia feedMedia3 = new FeedMedia(0, feedItem3, 2000, 0, 0, null, null, null, true, null, 0, 0);
feedItem3.setMedia(feedMedia3);
itemList.add(feedItem3);
return itemList;
}
use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class PlayLocalActionButton method onClick.
@Override
public void onClick(Context context) {
final FeedMedia media = item.getMedia();
if (media == null) {
return;
}
new PlaybackServiceStarter(context, media).callEvenIfRunning(true).startWhenPrepared(true).shouldStream(true).start();
if (media.getMediaType() == MediaType.VIDEO) {
context.startActivity(PlaybackService.getPlayerActivityIntent(context, media));
}
}
use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class DownloadActionButton method onClick.
@Override
public void onClick(Context context) {
final FeedMedia media = item.getMedia();
if (media == null || shouldNotDownload(media)) {
return;
}
UsageStatistics.logAction(UsageStatistics.ACTION_DOWNLOAD);
if (NetworkUtils.isEpisodeDownloadAllowed() || MobileDownloadHelper.userAllowedMobileDownloads()) {
DownloadService.download(context, false, DownloadRequestCreator.create(item.getMedia()).build());
} else if (MobileDownloadHelper.userChoseAddToQueue() && !item.isTagged(FeedItem.TAG_QUEUE)) {
DBWriter.addQueueItem(context, item);
Toast.makeText(context, R.string.added_to_queue_label, Toast.LENGTH_SHORT).show();
} else {
MobileDownloadHelper.confirmMobileDownload(context, item);
}
}
Aggregations