Compare commits
1
Commits
No files matched your search
@@ -382,7 +382,7 @@ function QualitySection({ user }: { user: CurrentUser }) {
|
|||||||
: "This device does not support Dolby Atmos playback."
|
: "This device does not support Dolby Atmos playback."
|
||||||
}
|
}
|
||||||
disabled={!dolbyAtmosSupported}
|
disabled={!dolbyAtmosSupported}
|
||||||
value={user.preferAtmos ?? false}
|
value={dolbyAtmosSupported && (user.preferAtmos ?? false)}
|
||||||
onValueChange={(checked) =>
|
onValueChange={(checked) =>
|
||||||
void updateAtmos({ preferAtmos: checked }).catch((error: Error) =>
|
void updateAtmos({ preferAtmos: checked }).catch((error: Error) =>
|
||||||
showError(error.message)
|
showError(error.message)
|
||||||
|
|||||||
@@ -1,19 +1,4 @@
|
|||||||
import { requireOptionalNativeModule } from "expo"
|
|
||||||
import { Platform } from "react-native"
|
import { Platform } from "react-native"
|
||||||
|
|
||||||
// E-AC-3 support varies by Android device. Older native builds fail closed.
|
// Android Dolby decoder reports do not reliably indicate working Atmos playback.
|
||||||
function supportsDolbyAtmos(): boolean {
|
export const dolbyAtmosSupported = Platform.OS === "ios"
|
||||||
if (Platform.OS === "ios") return true
|
|
||||||
if (Platform.OS !== "android") return false
|
|
||||||
try {
|
|
||||||
return (
|
|
||||||
requireOptionalNativeModule<{
|
|
||||||
supportsDolbyAtmos?: () => boolean
|
|
||||||
}>("AudioOutput")?.supportsDolbyAtmos?.() ?? false
|
|
||||||
)
|
|
||||||
} catch {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const dolbyAtmosSupported = supportsDolbyAtmos()
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||||
import { Platform } from "react-native"
|
import { Platform } from "react-native"
|
||||||
import type { AudioSource } from "expo-audio"
|
import type { AudioSource } from "expo-audio"
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ export function songPlayUrl(
|
|||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
if (Platform.OS === "ios") params.set("losslessFormat", "alac")
|
if (Platform.OS === "ios") params.set("losslessFormat", "alac")
|
||||||
if (quality) params.set("quality", quality)
|
if (quality) params.set("quality", quality)
|
||||||
if (preferAtmos) params.set("preferAtmos", "true")
|
if (dolbyAtmosSupported && preferAtmos) params.set("preferAtmos", "true")
|
||||||
const query = params.toString()
|
const query = params.toString()
|
||||||
return `${serverUrl}/api/song/${songId}/play${query ? `?${query}` : ""}`
|
return `${serverUrl}/api/song/${songId}/play${query ? `?${query}` : ""}`
|
||||||
}
|
}
|
||||||
@@ -66,7 +67,7 @@ export function songHlsPlaylistUrl(
|
|||||||
) {
|
) {
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
if (quality) params.set("quality", quality)
|
if (quality) params.set("quality", quality)
|
||||||
if (preferAtmos) params.set("preferAtmos", "true")
|
if (dolbyAtmosSupported && preferAtmos) params.set("preferAtmos", "true")
|
||||||
const query = params.toString()
|
const query = params.toString()
|
||||||
return `${serverUrl}/api/song/${songId}/play/hls${query ? `?${query}` : ""}`
|
return `${serverUrl}/api/song/${songId}/play/hls${query ? `?${query}` : ""}`
|
||||||
}
|
}
|
||||||
|
|||||||
-11
@@ -1,6 +1,5 @@
|
|||||||
package expo.modules.audiooutput
|
package expo.modules.audiooutput
|
||||||
|
|
||||||
import android.media.MediaCodecList
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.mediarouter.app.SystemOutputSwitcherDialogController
|
import androidx.mediarouter.app.SystemOutputSwitcherDialogController
|
||||||
import expo.modules.kotlin.functions.Queues
|
import expo.modules.kotlin.functions.Queues
|
||||||
@@ -11,16 +10,6 @@ class AudioOutputModule : Module() {
|
|||||||
override fun definition() = ModuleDefinition {
|
override fun definition() = ModuleDefinition {
|
||||||
Name("AudioOutput")
|
Name("AudioOutput")
|
||||||
|
|
||||||
Function("supportsDolbyAtmos") {
|
|
||||||
// Library Atmos tracks use E-AC-3. ExoPlayer needs a device decoder.
|
|
||||||
MediaCodecList(MediaCodecList.REGULAR_CODECS).codecInfos.any { codec ->
|
|
||||||
!codec.isEncoder && codec.supportedTypes.any { type ->
|
|
||||||
type.equals("audio/eac3", ignoreCase = true) ||
|
|
||||||
type.equals("audio/eac3-joc", ignoreCase = true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AsyncFunction("showPicker") {
|
AsyncFunction("showPicker") {
|
||||||
val activity = appContext.currentActivity
|
val activity = appContext.currentActivity
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || activity == null) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || activity == null) {
|
||||||
|
|||||||
Reference in new issue
Block a user