refactor(android): migrate AudioOutput to Kotlin (#3993)
* Rename .java to .kt * refactor(android): migrate AudioOutput to Kotlin * fix: lint error * refactor: rename of variables
This commit is contained in:
parent
df9ffde5fa
commit
5abc223db8
@ -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 + ")";
|
||||
}
|
||||
}
|
@ -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)"
|
||||
}
|
Loading…
Reference in New Issue
Block a user