Compare commits
15
Commits
No files matched your search
@@ -0,0 +1,25 @@
|
||||
# Mobile build variants
|
||||
|
||||
EAS profiles set `APP_VARIANT` to select the app identity in `app.config.ts`.
|
||||
Both iOS bundle identifiers and Android package names use these values:
|
||||
|
||||
| Profile | App name | Identifier |
|
||||
| --- | --- | --- |
|
||||
| development | oTunes (Development) | com.abunchofknowitalls.otunes.development |
|
||||
| preview | oTunes (Preview) | com.abunchofknowitalls.otunes.preview |
|
||||
| production | oTunes | com.abunchofknowitalls.otunes |
|
||||
|
||||
Build with `eas build --profile development`, `--profile preview`, or
|
||||
`--profile production` from this directory.
|
||||
|
||||
For local builds and Metro, select the same variant explicitly:
|
||||
|
||||
```sh
|
||||
APP_VARIANT=development pnpm ios
|
||||
APP_VARIANT=development pnpm android
|
||||
APP_VARIANT=development pnpm start
|
||||
```
|
||||
|
||||
An unset `APP_VARIANT` keeps the production identity. Unknown variants fail
|
||||
configuration. URL schemes are `otunes-development`, `otunes-preview`, and
|
||||
`otunes` respectively, allowing the apps to be installed together.
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { ConfigContext, ExpoConfig } from "expo/config"
|
||||
|
||||
export default ({ config }: ConfigContext): ExpoConfig => {
|
||||
const variant = process.env.APP_VARIANT ?? "production"
|
||||
if (!["development", "preview", "production"].includes(variant)) {
|
||||
throw new Error(`Unsupported APP_VARIANT: ${variant}`)
|
||||
}
|
||||
|
||||
const suffix = variant === "production" ? "" : `.${variant}`
|
||||
const nameSuffix =
|
||||
variant === "development"
|
||||
? " (Development)"
|
||||
: variant === "preview"
|
||||
? " (Preview)"
|
||||
: ""
|
||||
|
||||
return {
|
||||
...config,
|
||||
name: `${config.name}${nameSuffix}`,
|
||||
slug: config.slug!,
|
||||
scheme: variant === "production" ? "otunes" : `otunes-${variant}`,
|
||||
ios: {
|
||||
...config.ios,
|
||||
bundleIdentifier: `${config.ios!.bundleIdentifier}${suffix}`,
|
||||
},
|
||||
android: {
|
||||
...config.android,
|
||||
package: `${config.android!.package}${suffix}`,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { useAction, useMutation, useQuery } from "convex/react"
|
||||
import { Image } from "expo-image"
|
||||
import * as ImagePicker from "expo-image-picker"
|
||||
import { useState } from "react"
|
||||
import { router } from "expo-router"
|
||||
import {
|
||||
Platform,
|
||||
Pressable,
|
||||
@@ -374,7 +376,12 @@ function QualitySection({ user }: { user: CurrentUser }) {
|
||||
<SettingsCard title="Spatial Audio">
|
||||
<SwitchRow
|
||||
title="Prefer Dolby Atmos"
|
||||
subtitle="Use Atmos versions when they are available."
|
||||
subtitle={
|
||||
dolbyAtmosSupported
|
||||
? "Use Atmos versions when they are available."
|
||||
: "This device does not support Dolby Atmos playback."
|
||||
}
|
||||
disabled={!dolbyAtmosSupported}
|
||||
value={user.preferAtmos ?? false}
|
||||
onValueChange={(checked) =>
|
||||
void updateAtmos({ preferAtmos: checked }).catch((error: Error) =>
|
||||
@@ -459,7 +466,7 @@ function UsersSection({
|
||||
<SettingsCard title="Sign Up">
|
||||
<SwitchRow
|
||||
title="Disable account creation"
|
||||
subtitle="Stop people from registering themselves. Admins can still create accounts from the web app."
|
||||
subtitle="Stop people from registering themselves. Admins can still create accounts."
|
||||
value={appSettings?.disableAccountCreation ?? false}
|
||||
onValueChange={(checked) =>
|
||||
void setDisableCreation({ disabled: checked }).catch(
|
||||
@@ -473,6 +480,10 @@ function UsersSection({
|
||||
title="People"
|
||||
subtitle="Manage who can access this server."
|
||||
>
|
||||
<Button
|
||||
title="Create account"
|
||||
onPress={() => router.push("/(app)/create-account")}
|
||||
/>
|
||||
<View style={styles.userList}>
|
||||
{users.map((user, index) => (
|
||||
<View
|
||||
@@ -636,10 +647,12 @@ function SwitchRow({
|
||||
subtitle,
|
||||
value,
|
||||
onValueChange,
|
||||
disabled,
|
||||
}: {
|
||||
title: string
|
||||
subtitle?: string
|
||||
value: boolean
|
||||
disabled?: boolean
|
||||
onValueChange: (checked: boolean) => void
|
||||
}) {
|
||||
const colors = useThemeColors()
|
||||
@@ -656,6 +669,7 @@ function SwitchRow({
|
||||
</View>
|
||||
<Switch
|
||||
value={value}
|
||||
disabled={disabled}
|
||||
onValueChange={onValueChange}
|
||||
{...(Platform.OS === "android"
|
||||
? {
|
||||
|
||||
@@ -75,14 +75,25 @@ export default function AppLayout() {
|
||||
gestureDirection: "vertical",
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="create-account"
|
||||
options={{
|
||||
title: "Create account",
|
||||
presentation: "modal",
|
||||
headerLargeTitle: false,
|
||||
headerTransparent: false,
|
||||
headerStyle: { backgroundColor: "#000" },
|
||||
headerTintColor: "#fff",
|
||||
contentStyle: { backgroundColor: "#000" },
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="player"
|
||||
options={{
|
||||
headerShown: false,
|
||||
presentation:
|
||||
Platform.OS === "ios"
|
||||
? "transparentModal"
|
||||
: "fullScreenModal",
|
||||
// Keep the library visible behind the custom swipe animation.
|
||||
presentation: "transparentModal",
|
||||
contentStyle: { backgroundColor: "transparent" },
|
||||
animation: "slide_from_bottom",
|
||||
gestureEnabled: true,
|
||||
gestureDirection: "vertical",
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
import { useAction, useQuery } from "convex/react"
|
||||
import { ConvexError } from "convex/values"
|
||||
import { router, Stack } from "expo-router"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Switch,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native"
|
||||
import { SafeAreaView } from "react-native-safe-area-context"
|
||||
import { toast } from "sonner-native"
|
||||
|
||||
import { Button, Input, LoadingView } from "@/components/ui/primitives"
|
||||
import { colors, spacing } from "@/lib/theme"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
|
||||
export default function CreateAccountScreen() {
|
||||
const user = useQuery(api.auth.currentUser)
|
||||
const createUser = useAction(api.users.adminCreateUser)
|
||||
const [name, setName] = useState("")
|
||||
const [email, setEmail] = useState("")
|
||||
const [password, setPassword] = useState("")
|
||||
const [isAdmin, setIsAdmin] = useState(false)
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const pending = useRef(false)
|
||||
const mounted = useRef(true)
|
||||
|
||||
useEffect(() => {
|
||||
mounted.current = true
|
||||
return () => {
|
||||
mounted.current = false
|
||||
}
|
||||
}, [])
|
||||
|
||||
async function handleCreate() {
|
||||
if (pending.current || !user?.isAdmin) return
|
||||
setError(null)
|
||||
if (!name.trim() || !email.trim().includes("@") || password.length < 8) {
|
||||
setError(
|
||||
"Enter a name, valid email, and password of at least 8 characters."
|
||||
)
|
||||
return
|
||||
}
|
||||
pending.current = true
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await createUser({
|
||||
name: name.trim(),
|
||||
email: email.trim().toLowerCase(),
|
||||
password,
|
||||
isAdmin,
|
||||
})
|
||||
toast.success("Account created")
|
||||
if (mounted.current) router.back()
|
||||
} catch (error) {
|
||||
if (!mounted.current) return
|
||||
setError(
|
||||
error instanceof ConvexError && typeof error.data === "string"
|
||||
? error.data
|
||||
: "Could not create account. Try again."
|
||||
)
|
||||
} finally {
|
||||
pending.current = false
|
||||
if (mounted.current) setSubmitting(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView edges={["bottom", "left", "right"]} style={styles.screen}>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
gestureEnabled: !submitting,
|
||||
}}
|
||||
/>
|
||||
{user === undefined ? (
|
||||
<LoadingView />
|
||||
) : !user?.isAdmin ? (
|
||||
<Text style={[styles.text, styles.message]}>
|
||||
Admin access required.
|
||||
</Text>
|
||||
) : (
|
||||
<KeyboardAvoidingView
|
||||
style={styles.screen}
|
||||
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
||||
keyboardVerticalOffset={Platform.OS === "ios" ? 100 : 0}
|
||||
>
|
||||
<ScrollView
|
||||
contentContainerStyle={styles.form}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
keyboardDismissMode="on-drag"
|
||||
>
|
||||
<View style={styles.field}>
|
||||
<Text style={styles.label}>Name</Text>
|
||||
<Input
|
||||
accessibilityLabel="Name"
|
||||
value={name}
|
||||
onChangeText={setName}
|
||||
autoCapitalize="words"
|
||||
autoComplete="off"
|
||||
editable={!submitting}
|
||||
style={styles.input}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.field}>
|
||||
<Text style={styles.label}>Email</Text>
|
||||
<Input
|
||||
accessibilityLabel="Email"
|
||||
value={email}
|
||||
onChangeText={setEmail}
|
||||
keyboardType="email-address"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
autoComplete="off"
|
||||
editable={!submitting}
|
||||
style={styles.input}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.field}>
|
||||
<Text style={styles.label}>Password</Text>
|
||||
<Input
|
||||
accessibilityLabel="Password"
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
secureTextEntry
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
autoComplete="new-password"
|
||||
placeholder="At least 8 characters"
|
||||
editable={!submitting}
|
||||
style={styles.input}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.row}>
|
||||
<Text style={styles.text}>Grant admin access</Text>
|
||||
<Switch
|
||||
accessibilityLabel="Grant admin access"
|
||||
trackColor={{
|
||||
false: colors.dark.muted,
|
||||
true: colors.dark.primary,
|
||||
}}
|
||||
thumbColor={colors.dark.foreground}
|
||||
value={isAdmin}
|
||||
onValueChange={setIsAdmin}
|
||||
disabled={submitting}
|
||||
/>
|
||||
</View>
|
||||
{error ? (
|
||||
<Text accessibilityRole="alert" style={styles.error}>
|
||||
{error}
|
||||
</Text>
|
||||
) : null}
|
||||
<Button
|
||||
title={submitting ? "Creating account…" : "Create account"}
|
||||
disabled={submitting}
|
||||
onPress={() => void handleCreate()}
|
||||
tint={{
|
||||
background: colors.dark.primary,
|
||||
foreground: colors.dark.primaryForeground,
|
||||
}}
|
||||
/>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
)}
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
screen: { flex: 1, backgroundColor: "#000" },
|
||||
form: { padding: spacing.lg, gap: spacing.lg },
|
||||
field: { gap: spacing.sm },
|
||||
label: {
|
||||
color: colors.dark.mutedForeground,
|
||||
fontSize: 12,
|
||||
fontWeight: "600",
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 0.6,
|
||||
},
|
||||
text: { color: colors.dark.foreground, fontSize: 16, flexShrink: 1 },
|
||||
input: {
|
||||
backgroundColor: colors.dark.muted,
|
||||
color: colors.dark.foreground,
|
||||
borderColor: colors.dark.border,
|
||||
},
|
||||
row: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: spacing.md,
|
||||
minHeight: 48,
|
||||
},
|
||||
message: { padding: spacing.lg },
|
||||
error: { color: colors.dark.destructive, fontSize: 14, lineHeight: 20 },
|
||||
})
|
||||
@@ -1,3 +1,4 @@
|
||||
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||
import { NavigationBar } from "expo-navigation-bar"
|
||||
import { MusicEntityView } from "@/components/music-entity-view"
|
||||
import { Stack, useRouter } from "expo-router"
|
||||
@@ -91,6 +92,7 @@ export default function PlayerScreen() {
|
||||
} = usePlayback()
|
||||
const { volume, setVolume, available: volumeAvailable } = useSystemVolume()
|
||||
const [showQueue, setShowQueue] = useState(false)
|
||||
const [isDismissing, setIsDismissing] = useState(false)
|
||||
const [stageHeight, setStageHeight] = useState(0)
|
||||
const [scrubTime, setScrubTime] = useState<number | null>(null)
|
||||
const user = useCachedQuery(api.auth.currentUser)
|
||||
@@ -103,7 +105,7 @@ export default function PlayerScreen() {
|
||||
? playbackFormat(
|
||||
playbackInfo.files,
|
||||
user.playbackQuality,
|
||||
user.preferAtmos ?? false
|
||||
dolbyAtmosSupported && (user.preferAtmos ?? false)
|
||||
)
|
||||
: null
|
||||
|
||||
@@ -162,6 +164,7 @@ export default function PlayerScreen() {
|
||||
event.translationY > DISMISS_DISTANCE ||
|
||||
event.velocityY > DISMISS_VELOCITY
|
||||
) {
|
||||
scheduleOnRN(setIsDismissing, true)
|
||||
dismissY.value = withTiming(
|
||||
windowHeight,
|
||||
{ duration: 220 },
|
||||
@@ -221,7 +224,11 @@ export default function PlayerScreen() {
|
||||
{Platform.OS === "android" ? (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{ statusBarStyle: colors.isDark ? "light" : "dark" }}
|
||||
options={{
|
||||
statusBarStyle: colors.isDark ? "light" : "dark",
|
||||
// The swipe already animates the player offscreen.
|
||||
animation: isDismissing ? "none" : "slide_from_bottom",
|
||||
}}
|
||||
/>
|
||||
<NavigationBar style={colors.isDark ? "light" : "dark"} />
|
||||
</>
|
||||
@@ -391,6 +398,7 @@ export default function PlayerScreen() {
|
||||
<PlayerSlider
|
||||
accessibilityLabel="Volume"
|
||||
commitHoldMs={0}
|
||||
animateValueChanges
|
||||
value={volume}
|
||||
maximumValue={1}
|
||||
fillColor={colors.sliderFill}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useMemo, useRef, type ReactNode } from "react"
|
||||
import { StyleSheet, View } from "react-native"
|
||||
import { Gesture, GestureDetector } from "react-native-gesture-handler"
|
||||
import Animated, {
|
||||
cancelAnimation,
|
||||
interpolate,
|
||||
interpolateColor,
|
||||
useAnimatedStyle,
|
||||
@@ -35,6 +36,7 @@ export function PlayerSlider({
|
||||
trailing,
|
||||
accessibilityLabel,
|
||||
commitHoldMs = COMMIT_HOLD_MS,
|
||||
animateValueChanges = false,
|
||||
}: {
|
||||
value: number
|
||||
maximumValue: number
|
||||
@@ -47,6 +49,7 @@ export function PlayerSlider({
|
||||
leading?: ReactNode
|
||||
trailing?: ReactNode
|
||||
accessibilityLabel: string
|
||||
animateValueChanges?: boolean
|
||||
/** Seeking needs a hold while playback catches up; system volume does not. */
|
||||
commitHoldMs?: number
|
||||
}) {
|
||||
@@ -60,8 +63,11 @@ export function PlayerSlider({
|
||||
|
||||
useEffect(() => {
|
||||
if (dragging.value || Date.now() < holdUntil.current) return
|
||||
fraction.value = clamp(value / max)
|
||||
}, [dragging, fraction, max, value])
|
||||
const next = clamp(value / max)
|
||||
fraction.value = animateValueChanges
|
||||
? withTiming(next, { duration: 160 })
|
||||
: next
|
||||
}, [animateValueChanges, dragging, fraction, max, value])
|
||||
|
||||
const callbacks = useRef({
|
||||
onValueChange,
|
||||
@@ -100,6 +106,7 @@ export function PlayerSlider({
|
||||
active.value = withSpring(1, { duration: 250, dampingRatio: 0.8 })
|
||||
})
|
||||
.onStart(() => {
|
||||
cancelAnimation(fraction)
|
||||
dragging.value = true
|
||||
startFraction.value = fraction.value
|
||||
scheduleOnRN(start)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||
import {
|
||||
createAudioPlaylist,
|
||||
setAudioModeAsync,
|
||||
@@ -313,7 +314,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
? JSON.stringify([
|
||||
user._id,
|
||||
user.playbackQuality,
|
||||
user.preferAtmos ?? false,
|
||||
dolbyAtmosSupported && (user.preferAtmos ?? false),
|
||||
])
|
||||
: ""
|
||||
|
||||
@@ -625,7 +626,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
if (!isCurrentLoad()) return
|
||||
|
||||
const loadKey = `${user.playbackQuality}:${user.preferAtmos ?? false}:${cookieHeader}`
|
||||
const loadKey = `${user.playbackQuality}:${dolbyAtmosSupported && (user.preferAtmos ?? false)}:${cookieHeader}`
|
||||
const needsRebuild =
|
||||
loadedLoadKeyRef.current !== loadKey ||
|
||||
nativePlaylistNeedsRebuild(
|
||||
@@ -667,7 +668,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
const plan = playbackStreamPlan(
|
||||
song.files,
|
||||
user.playbackQuality,
|
||||
user.preferAtmos ?? false
|
||||
dolbyAtmosSupported && (user.preferAtmos ?? false)
|
||||
)
|
||||
sources.set(
|
||||
song.id,
|
||||
|
||||
@@ -5,13 +5,22 @@
|
||||
},
|
||||
"build": {
|
||||
"development": {
|
||||
"env": {
|
||||
"APP_VARIANT": "development"
|
||||
},
|
||||
"developmentClient": true,
|
||||
"distribution": "internal"
|
||||
},
|
||||
"preview": {
|
||||
"env": {
|
||||
"APP_VARIANT": "preview"
|
||||
},
|
||||
"distribution": "internal"
|
||||
},
|
||||
"production": {
|
||||
"env": {
|
||||
"APP_VARIANT": "production"
|
||||
},
|
||||
"autoIncrement": true
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { requireOptionalNativeModule, type EventEmitter } from "expo"
|
||||
import { useFocusEffect } from "expo-router"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { AppState } from "react-native"
|
||||
import { AppState, Platform } from "react-native"
|
||||
|
||||
type VolumeState = { volume: number; available: boolean }
|
||||
type VolumeEvents = { onVolumeChange: (state: VolumeState) => void }
|
||||
interface SystemVolumeModule extends EventEmitter<VolumeEvents> {
|
||||
setPlayerVisible?(visible: boolean): Promise<void>
|
||||
getState(): Promise<VolumeState>
|
||||
setVolume(volume: number): Promise<void>
|
||||
}
|
||||
@@ -18,6 +20,16 @@ export function useSystemVolume() {
|
||||
available: false,
|
||||
})
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
if (Platform.OS !== "ios" || !native?.setPlayerVisible) return
|
||||
void native.setPlayerVisible(true).catch(() => {})
|
||||
return () => {
|
||||
void native.setPlayerVisible?.(false).catch(() => {})
|
||||
}
|
||||
}, [])
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!native) return
|
||||
let active = true
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { requireOptionalNativeModule } from "expo"
|
||||
import { Platform } from "react-native"
|
||||
|
||||
// E-AC-3 support varies by Android device. Older native builds fail closed.
|
||||
function supportsDolbyAtmos(): boolean {
|
||||
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 { Platform } from "react-native"
|
||||
import type { AudioSource } from "expo-audio"
|
||||
|
||||
export type PlaybackQuality = "low" | "medium" | "high" | "lossless"
|
||||
@@ -50,6 +51,7 @@ export function songPlayUrl(
|
||||
preferAtmos: boolean | undefined
|
||||
) {
|
||||
const params = new URLSearchParams()
|
||||
if (Platform.OS === "ios") params.set("losslessFormat", "alac")
|
||||
if (quality) params.set("quality", quality)
|
||||
if (preferAtmos) params.set("preferAtmos", "true")
|
||||
const query = params.toString()
|
||||
|
||||
+11
@@ -1,5 +1,6 @@
|
||||
package expo.modules.audiooutput
|
||||
|
||||
import android.media.MediaCodecList
|
||||
import android.os.Build
|
||||
import androidx.mediarouter.app.SystemOutputSwitcherDialogController
|
||||
import expo.modules.kotlin.functions.Queues
|
||||
@@ -10,6 +11,16 @@ class AudioOutputModule : Module() {
|
||||
override fun definition() = ModuleDefinition {
|
||||
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") {
|
||||
val activity = appContext.currentActivity
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || activity == null) {
|
||||
|
||||
@@ -7,24 +7,37 @@ public class AudioOutputModule: Module {
|
||||
|
||||
View(AudioOutputView.self) {
|
||||
Prop("tint") { (view: AudioOutputView, color: UIColor) in
|
||||
view.picker.tintColor = color
|
||||
view.icon.tintColor = color
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class AudioOutputView: ExpoView {
|
||||
let picker = AVRoutePickerView()
|
||||
private let picker = AVRoutePickerView()
|
||||
let icon = UIImageView(
|
||||
image: UIImage(
|
||||
systemName: "airplay.audio",
|
||||
withConfiguration: UIImage.SymbolConfiguration(pointSize: 27, weight: .semibold)
|
||||
)
|
||||
)
|
||||
|
||||
required init(appContext: AppContext? = nil) {
|
||||
super.init(appContext: appContext)
|
||||
picker.prioritizesVideoDevices = false
|
||||
picker.backgroundColor = .clear
|
||||
// Keep the native picker interactive without its route-dependent icon styling.
|
||||
picker.layer.opacity = 0
|
||||
addSubview(picker)
|
||||
icon.contentMode = .center
|
||||
icon.isUserInteractionEnabled = false
|
||||
icon.isAccessibilityElement = false
|
||||
addSubview(icon)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
picker.frame = bounds
|
||||
icon.frame = bounds
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,20 @@ final class SystemVolume: Module {
|
||||
Events("onVolumeChange")
|
||||
|
||||
AsyncFunction("getState") { () -> [String: Any] in
|
||||
self.prepareVolumeView()
|
||||
return self.state()
|
||||
}.runOnQueue(.main)
|
||||
|
||||
AsyncFunction("setPlayerVisible") { (visible: Bool) in
|
||||
if visible {
|
||||
self.prepareVolumeView()
|
||||
} else {
|
||||
self.volumeView?.removeFromSuperview()
|
||||
self.volumeView = nil
|
||||
}
|
||||
}.runOnQueue(.main)
|
||||
|
||||
AsyncFunction("setVolume") { (value: Double) in
|
||||
self.prepareVolumeView()
|
||||
guard value.isFinite,
|
||||
guard value.isFinite, self.volumeView?.window != nil,
|
||||
let slider = self.volumeView?.subviews.compactMap({ $0 as? UISlider }).first
|
||||
else { return }
|
||||
slider.setValue(Float(min(1, max(0, value))), animated: false)
|
||||
|
||||
@@ -122,11 +122,7 @@ export async function GET(
|
||||
}))!
|
||||
|
||||
const quality = request.nextUrl.searchParams.get("quality") as
|
||||
| "low"
|
||||
| "medium"
|
||||
| "high"
|
||||
| "lossless"
|
||||
| null
|
||||
"low" | "medium" | "high" | "lossless" | null
|
||||
|
||||
const preferAtmos =
|
||||
request.nextUrl.searchParams.get("preferAtmos") === "true"
|
||||
@@ -157,7 +153,11 @@ export async function GET(
|
||||
const metadata = await music.parseFile(song.files[originalCodec])
|
||||
|
||||
if (!transcodeNeeded && originalCodec === "lossless") {
|
||||
if (browser.name === "Safari" && metadata.format.codec === "ALAC") {
|
||||
// Native iOS playback does not identify itself as Safari.
|
||||
const acceptsAlac =
|
||||
browser.name === "Safari" ||
|
||||
request.nextUrl.searchParams.get("losslessFormat") === "alac"
|
||||
if (acceptsAlac && metadata.format.codec === "ALAC") {
|
||||
try {
|
||||
return await streamFileResponse(
|
||||
request,
|
||||
|
||||
Reference in new issue
Block a user