diff --git a/android/src/main/java/com/brentvatne/exoplayer/AudioOutput.java b/android/src/main/java/com/brentvatne/exoplayer/AudioOutput.java deleted file mode 100644 index 90cd4f45..00000000 --- a/android/src/main/java/com/brentvatne/exoplayer/AudioOutput.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.brentvatne.exoplayer; - -import android.annotation.SuppressLint; - -import androidx.annotation.NonNull; -import androidx.media3.common.C; - -@SuppressLint("InlinedApi") -public enum AudioOutput { - SPEAKER("speaker", C.STREAM_TYPE_MUSIC), - EARPIECE("earpiece", C.STREAM_TYPE_VOICE_CALL); - - private final @C.StreamType int streamType; - private final String mName; - - AudioOutput(final String name, @C.StreamType int stream) { - mName = name; - streamType = stream; - } - - public static AudioOutput get(String name) { - for (AudioOutput d : values()) { - if (d.mName.equalsIgnoreCase(name)) - return d; - } - return SPEAKER; - } - - public int getStreamType() { - return streamType; - } - - @NonNull - @Override - public String toString() { - return getClass().getSimpleName() + "(" + this.mName + ", " + streamType + ")"; - } -} \ No newline at end of file diff --git a/android/src/main/java/com/brentvatne/exoplayer/AudioOutput.kt b/android/src/main/java/com/brentvatne/exoplayer/AudioOutput.kt new file mode 100644 index 00000000..7022600a --- /dev/null +++ b/android/src/main/java/com/brentvatne/exoplayer/AudioOutput.kt @@ -0,0 +1,25 @@ +package com.brentvatne.exoplayer + +import android.annotation.SuppressLint +import androidx.media3.common.C + +@SuppressLint("InlinedApi") +enum class AudioOutput(private val outputName: String, @C.StreamType val streamType: Int) { + + SPEAKER("speaker", C.STREAM_TYPE_MUSIC), + EARPIECE("earpiece", C.STREAM_TYPE_VOICE_CALL); + + companion object { + @JvmStatic + fun get(name: String): AudioOutput { + for (entry in entries) { + if (entry.outputName.equals(name, ignoreCase = true)) { + return entry + } + } + return SPEAKER + } + } + + override fun toString(): String = "${javaClass.simpleName}($outputName, $streamType)" +}