Search in sources :

Example 21 with FeedMedia

use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.

the class DbWriterTest method playbackHistorySetup.

private FeedMedia playbackHistorySetup(Date playbackCompletionDate) {
    Feed feed = new Feed("url", null, "title");
    feed.setItems(new ArrayList<>());
    FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
    FeedMedia media = new FeedMedia(0, item, 10, 0, 1, "mime", null, "url", false, playbackCompletionDate, 0, 0);
    feed.getItems().add(item);
    item.setMedia(media);
    PodDBAdapter adapter = PodDBAdapter.getInstance();
    adapter.open();
    adapter.setCompleteFeed(feed);
    adapter.close();
    assertTrue(media.getId() != 0);
    return media;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Date(java.util.Date) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 22 with FeedMedia

use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.

the class PlaybackVolumeUpdaterTest method updatesPreferencesForLoadedFeedMediaIfPlayerStatusIsPaused.

@Test
public void updatesPreferencesForLoadedFeedMediaIfPlayerStatusIsPaused() {
    PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
    when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.PAUSED);
    FeedMedia feedMedia = mockFeedMedia();
    when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
    FeedPreferences feedPreferences = feedMedia.getItem().getFeed().getPreferences();
    playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
    verify(feedPreferences, times(1)).setVolumeAdaptionSetting(VolumeAdaptionSetting.LIGHT_REDUCTION);
    verify(mediaPlayer, never()).pause(anyBoolean(), anyBoolean());
    verify(mediaPlayer, never()).resume();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Test(org.junit.Test)

Example 23 with FeedMedia

use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.

the class PlaybackVolumeUpdaterTest method updatesPreferencesForLoadedFeedMediaIfPlayerStatusIsPreparing.

@Test
public void updatesPreferencesForLoadedFeedMediaIfPlayerStatusIsPreparing() {
    PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
    when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.PREPARING);
    FeedMedia feedMedia = mockFeedMedia();
    when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
    FeedPreferences feedPreferences = feedMedia.getItem().getFeed().getPreferences();
    playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
    verify(feedPreferences, times(1)).setVolumeAdaptionSetting(VolumeAdaptionSetting.LIGHT_REDUCTION);
    verify(mediaPlayer, never()).pause(anyBoolean(), anyBoolean());
    verify(mediaPlayer, never()).resume();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Test(org.junit.Test)

Example 24 with FeedMedia

use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.

the class PlaybackVolumeUpdaterTest method noChangeIfPlayerStatusIsIndeterminate.

@Test
public void noChangeIfPlayerStatusIsIndeterminate() {
    PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
    when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.INDETERMINATE);
    FeedMedia feedMedia = mockFeedMedia();
    when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
    playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.OFF);
    verify(mediaPlayer, never()).pause(anyBoolean(), anyBoolean());
    verify(mediaPlayer, never()).resume();
}
Also used : FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Test(org.junit.Test)

Example 25 with FeedMedia

use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.

the class PlaybackVolumeUpdaterTest method updatesPreferencesForLoadedFeedMediaIfPlayerStatusIsPrepared.

@Test
public void updatesPreferencesForLoadedFeedMediaIfPlayerStatusIsPrepared() {
    PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
    when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.PREPARED);
    FeedMedia feedMedia = mockFeedMedia();
    when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
    FeedPreferences feedPreferences = feedMedia.getItem().getFeed().getPreferences();
    playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
    verify(feedPreferences, times(1)).setVolumeAdaptionSetting(VolumeAdaptionSetting.LIGHT_REDUCTION);
    verify(mediaPlayer, never()).pause(anyBoolean(), anyBoolean());
    verify(mediaPlayer, never()).resume();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Test(org.junit.Test)

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