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:
Seyed Mostafa Hasani 2024-07-15 13:31:32 +03:30 committed by GitHub
parent df9ffde5fa
commit 5abc223db8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 38 deletions

View File

@ -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 + ")";
}
}

View File

@ -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)"
}