Search in sources :

Example 26 with FeedMedia

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();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Test(org.junit.Test)

Example 27 with FeedMedia

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;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 28 with FeedMedia

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;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 29 with FeedMedia

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));
    }
}
Also used : PlaybackServiceStarter(de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia)

Example 30 with FeedMedia

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);
    }
}
Also used : FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia)

Aggregations

FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)91 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)46 Test (org.junit.Test)28 Feed (de.danoeh.antennapod.model.feed.Feed)26 Date (java.util.Date)25 ArrayList (java.util.ArrayList)18 FeedPreferences (de.danoeh.antennapod.model.feed.FeedPreferences)15 File (java.io.File)15 Playable (de.danoeh.antennapod.model.playback.Playable)8 View (android.view.View)6 NonNull (androidx.annotation.NonNull)6 Context (android.content.Context)5 Log (android.util.Log)5 PlaybackServiceStarter (de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter)5 Cursor (android.database.Cursor)4 Nullable (androidx.annotation.Nullable)4 R (de.danoeh.antennapod.R)4 DownloadRequest (de.danoeh.antennapod.core.service.download.DownloadRequest)4 DownloadService (de.danoeh.antennapod.core.service.download.DownloadService)4 Intent (android.content.Intent)3