Changeset 14183 in josm


Ignore:
Timestamp:
2018-08-27T13:17:01+02:00 (3 months ago)
Author:
Don-vip
Message:

see #16682 - deprecate JavaFX core media player to move it to new openjfx plugin

Location:
trunk/src/org/openstreetmap/josm/io/audio
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/audio/AudioPlayer.java

    r14095 r14183  
    44import java.io.IOException;
    55import java.net.URL;
     6import java.util.Objects;
    67
    78import org.openstreetmap.josm.spi.preferences.Config;
     
    4748
    4849    private State state;
     50    private static Class<? extends SoundPlayer> soundPlayerClass;
    4951    private SoundPlayer soundPlayer;
    5052    private URL playingUrl;
     
    266268    }
    267269
     270    @SuppressWarnings("unchecked")
    268271    private AudioPlayer() {
    269272        state = State.INITIALIZING;
     
    273276        double calibration = Config.getPref().getDouble("audio.calibration", 1.0 /* default, ratio */);
    274277        try {
    275             soundPlayer = (SoundPlayer) Class.forName("org.openstreetmap.josm.io.audio.fx.JavaFxMediaPlayer")
    276                     .getDeclaredConstructor().newInstance();
     278            if (soundPlayerClass == null) {
     279                // To remove when switching to Java 11
     280                soundPlayerClass = (Class<? extends SoundPlayer>) Class.forName(
     281                        "org.openstreetmap.josm.io.audio.fx.JavaFxMediaPlayer");
     282            }
     283            soundPlayer = soundPlayerClass.getDeclaredConstructor().newInstance();
    277284        } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
    278285            Logging.debug(e);
     
    355362        this.playingUrl = playingUrl;
    356363    }
     364
     365    /**
     366     * Returns the custom sound player class, if any.
     367     * @return the custom sound player class, or {@code null}
     368     * @since 14183
     369     */
     370    public static Class<? extends SoundPlayer> getSoundPlayerClass() {
     371        return soundPlayerClass;
     372    }
     373
     374    /**
     375     * Sets the custom sound player class to override default core player.
     376     * Must be called before the first audio method invocation.
     377     * @param playerClass custom sound player class to override default core player
     378     * @since 14183
     379     */
     380    public static void setSoundPlayerClass(Class<? extends SoundPlayer> playerClass) {
     381        if (audioPlayer != null) {
     382            throw new IllegalStateException("Audio player already initialized");
     383        }
     384        soundPlayerClass = Objects.requireNonNull(playerClass);
     385    }
    357386}
  • trunk/src/org/openstreetmap/josm/io/audio/fx/JavaFxMediaPlayer.java

    r13829 r14183  
    3434 * </ul>
    3535 * @since 12328
     36 * @deprecated MP3 support moved to openjfx plugin as JavaFX is gone with Java 11.
    3637 */
     38@Deprecated
    3739public class JavaFxMediaPlayer implements SoundPlayer {
    3840
  • trunk/src/org/openstreetmap/josm/io/audio/fx/package-info.java

    r13819 r14183  
    44 * Provides the classes for Audio mapping features requiring JavaFX.
    55 * The package is distinct to ease the decoupling between JOSM and JavaFX as an optional dependence.
     6 * @deprecated MP3 support moved to openjfx plugin as JavaFX is gone with Java 11.
    67 */
    78package org.openstreetmap.josm.io.audio.fx;
Note: See TracChangeset for help on using the changeset viewer.