Search in sources :

Example 1 with VolumeAdaptionSetting

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

the class LocalPSMP method setVolumeSync.

/**
 * Sets the playback volume.
 * This method is executed on the caller's thread.
 */
private void setVolumeSync(float volumeLeft, float volumeRight) {
    playerLock.lock();
    Playable playable = getPlayable();
    if (playable instanceof FeedMedia) {
        FeedMedia feedMedia = (FeedMedia) playable;
        FeedPreferences preferences = feedMedia.getItem().getFeed().getPreferences();
        VolumeAdaptionSetting volumeAdaptionSetting = preferences.getVolumeAdaptionSetting();
        float adaptionFactor = volumeAdaptionSetting.getAdaptionFactor();
        volumeLeft *= adaptionFactor;
        volumeRight *= adaptionFactor;
    }
    mediaPlayer.setVolume(volumeLeft, volumeRight);
    Log.d(TAG, "Media player volume was set to " + volumeLeft + " " + volumeRight);
    playerLock.unlock();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) Playable(de.danoeh.antennapod.model.playback.Playable) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) VolumeAdaptionSetting(de.danoeh.antennapod.model.feed.VolumeAdaptionSetting)

Example 2 with VolumeAdaptionSetting

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

the class VolumeAdaptionSettingTest method mapHeavyReductionToInteger.

@Test
public void mapHeavyReductionToInteger() {
    VolumeAdaptionSetting setting = VolumeAdaptionSetting.HEAVY_REDUCTION;
    assertThat(setting.toInteger(), is(equalTo(2)));
}
Also used : VolumeAdaptionSetting(de.danoeh.antennapod.model.feed.VolumeAdaptionSetting) Test(org.junit.Test)

Example 3 with VolumeAdaptionSetting

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

the class VolumeAdaptionSettingTest method mapLightReductionToInteger.

@Test
public void mapLightReductionToInteger() {
    VolumeAdaptionSetting setting = VolumeAdaptionSetting.LIGHT_REDUCTION;
    assertThat(setting.toInteger(), is(equalTo(1)));
}
Also used : VolumeAdaptionSetting(de.danoeh.antennapod.model.feed.VolumeAdaptionSetting) Test(org.junit.Test)

Example 4 with VolumeAdaptionSetting

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

the class FeedPreferencesCursorMapper method convert.

/**
 * Create a {@link FeedPreferences} instance from a database row (cursor).
 */
@NonNull
public static FeedPreferences convert(@NonNull Cursor cursor) {
    int indexId = cursor.getColumnIndex(PodDBAdapter.KEY_ID);
    int indexAutoDownload = cursor.getColumnIndex(PodDBAdapter.KEY_AUTO_DOWNLOAD_ENABLED);
    int indexAutoRefresh = cursor.getColumnIndex(PodDBAdapter.KEY_KEEP_UPDATED);
    int indexAutoDeleteAction = cursor.getColumnIndex(PodDBAdapter.KEY_AUTO_DELETE_ACTION);
    int indexVolumeAdaption = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_VOLUME_ADAPTION);
    int indexUsername = cursor.getColumnIndex(PodDBAdapter.KEY_USERNAME);
    int indexPassword = cursor.getColumnIndex(PodDBAdapter.KEY_PASSWORD);
    int indexIncludeFilter = cursor.getColumnIndex(PodDBAdapter.KEY_INCLUDE_FILTER);
    int indexExcludeFilter = cursor.getColumnIndex(PodDBAdapter.KEY_EXCLUDE_FILTER);
    int indexMinimalDurationFilter = cursor.getColumnIndex(PodDBAdapter.KEY_MINIMAL_DURATION_FILTER);
    int indexFeedPlaybackSpeed = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_PLAYBACK_SPEED);
    int indexAutoSkipIntro = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_INTRO);
    int indexAutoSkipEnding = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_ENDING);
    int indexEpisodeNotification = cursor.getColumnIndex(PodDBAdapter.KEY_EPISODE_NOTIFICATION);
    int indexTags = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_TAGS);
    long feedId = cursor.getLong(indexId);
    boolean autoDownload = cursor.getInt(indexAutoDownload) > 0;
    boolean autoRefresh = cursor.getInt(indexAutoRefresh) > 0;
    int autoDeleteActionIndex = cursor.getInt(indexAutoDeleteAction);
    FeedPreferences.AutoDeleteAction autoDeleteAction = FeedPreferences.AutoDeleteAction.values()[autoDeleteActionIndex];
    int volumeAdaptionValue = cursor.getInt(indexVolumeAdaption);
    VolumeAdaptionSetting volumeAdaptionSetting = VolumeAdaptionSetting.fromInteger(volumeAdaptionValue);
    String username = cursor.getString(indexUsername);
    String password = cursor.getString(indexPassword);
    String includeFilter = cursor.getString(indexIncludeFilter);
    String excludeFilter = cursor.getString(indexExcludeFilter);
    int minimalDurationFilter = cursor.getInt(indexMinimalDurationFilter);
    float feedPlaybackSpeed = cursor.getFloat(indexFeedPlaybackSpeed);
    int feedAutoSkipIntro = cursor.getInt(indexAutoSkipIntro);
    int feedAutoSkipEnding = cursor.getInt(indexAutoSkipEnding);
    boolean showNotification = cursor.getInt(indexEpisodeNotification) > 0;
    String tagsString = cursor.getString(indexTags);
    if (TextUtils.isEmpty(tagsString)) {
        tagsString = FeedPreferences.TAG_ROOT;
    }
    return new FeedPreferences(feedId, autoDownload, autoRefresh, autoDeleteAction, volumeAdaptionSetting, username, password, new FeedFilter(includeFilter, excludeFilter, minimalDurationFilter), feedPlaybackSpeed, feedAutoSkipIntro, feedAutoSkipEnding, showNotification, new HashSet<>(Arrays.asList(tagsString.split(FeedPreferences.TAG_SEPARATOR))));
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) VolumeAdaptionSetting(de.danoeh.antennapod.model.feed.VolumeAdaptionSetting) FeedFilter(de.danoeh.antennapod.model.feed.FeedFilter) NonNull(androidx.annotation.NonNull)

Example 5 with VolumeAdaptionSetting

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

the class VolumeAdaptionSettingTest method mapOffToInteger.

@Test
public void mapOffToInteger() {
    VolumeAdaptionSetting setting = VolumeAdaptionSetting.OFF;
    assertThat(setting.toInteger(), is(equalTo(0)));
}
Also used : VolumeAdaptionSetting(de.danoeh.antennapod.model.feed.VolumeAdaptionSetting) Test(org.junit.Test)

Aggregations

VolumeAdaptionSetting (de.danoeh.antennapod.model.feed.VolumeAdaptionSetting)5 Test (org.junit.Test)3 FeedPreferences (de.danoeh.antennapod.model.feed.FeedPreferences)2 NonNull (androidx.annotation.NonNull)1 FeedFilter (de.danoeh.antennapod.model.feed.FeedFilter)1 FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)1 Playable (de.danoeh.antennapod.model.playback.Playable)1