Modern Apps git

← Modern-Apps.git

youpipe: cast the video to a TV instead of mirroring

Commit
085dcdec04c8a432d6e8679e26b3b6d579e78d8c
Author
vayun-mathur <[email protected]>
When
2026-08-21 20:43 UTC (3 months ago)
Parents
bf9593f

Diff

library/ui/src/main/java/com/vayunmathur/library/ui/ExternalIntents.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/ExternalIntents.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/ExternalIntents.ktindex 5694119ab9..619da740e9 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/ExternalIntents.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/ExternalIntents.kt@@ -44,6 +44,19 @@ object ExternalIntents {     fun openUrl(context: Context, url: String, failureMessage: String? = null): Boolean =         launch(context, Intent(Intent.ACTION_VIEW, url.toUri()), failureMessage) +    /**+     * Open [packageName]'s store listing, so a missing app can be installed.+     *+     * `:appstore` claims the `market` scheme outright and turns `?id=` into a package, so this lands+     * on that app's install page. Reports rather than throws when nothing handles it, like everything+     * else here.+     */+    fun openAppListing(+        context: Context,+        packageName: String,+        failureMessage: String? = null,+    ): Boolean = openUrl(context, "market://details?id=$packageName", failureMessage)+     /** Open a file by content URI, granting read access to the receiving app. */     fun openFile(         context: Context,
youpipe/build.gradle.kts
diff --git a/youpipe/build.gradle.kts b/youpipe/build.gradle.ktsindex 66fb21714e..399e4040e8 100644--- a/youpipe/build.gradle.kts+++ b/youpipe/build.gradle.kts@@ -39,6 +39,8 @@ android { dependencies {     implementation(project(":library:image"))     implementation(project(":youpipe:extractor"))+    // Puts the video on a TV through the installed Cast app: a Surface and a PCM pipe, no sockets.+    implementation(project(":sdk:cast"))     implementation(libs.quickjs.kt)     implementation(libs.androidx.webkit) 
youpipe/src/main/AndroidManifest.xml
diff --git a/youpipe/src/main/AndroidManifest.xml b/youpipe/src/main/AndroidManifest.xmlindex 98c9ca0668..1507a5d47e 100644--- a/youpipe/src/main/AndroidManifest.xml+++ b/youpipe/src/main/AndroidManifest.xml@@ -9,6 +9,15 @@     <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />     <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> +    <!-- Casting is brokered through the installed Cast app, so nothing about the network is needed+         here: MA Cast owns the sockets, the pairing and the encoders. Only this signature permission,+         and visibility of the package so the capability probe can resolve it. -->+    <uses-permission android:name="com.vayunmathur.cast.permission.STREAM_CONTENT" />++    <queries>+        <package android:name="com.vayunmathur.cast" />+    </queries>+     <application         android:name=".YouPipeApplication"         android:allowBackup="true"
youpipe/src/main/java/com/vayunmathur/youpipe/platform/CastPlayback.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/platform/CastPlayback.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/platform/CastPlayback.ktnew file mode 100644index 0000000000..ffcf0280b9--- /dev/null+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/platform/CastPlayback.kt@@ -0,0 +1,266 @@+package com.vayunmathur.youpipe.platform++import android.content.Context+import android.os.ParcelFileDescriptor+import android.util.Log+import android.view.Surface+import androidx.annotation.OptIn+import androidx.media3.common.util.UnstableApi+import androidx.media3.exoplayer.audio.TeeAudioProcessor+import com.vayunmathur.sdk.cast.CastClient+import com.vayunmathur.sdk.cast.CastContract+import com.vayunmathur.sdk.cast.CastException+import kotlinx.coroutines.flow.MutableStateFlow+import kotlinx.coroutines.flow.StateFlow+import kotlinx.coroutines.flow.asStateFlow+import java.io.FileOutputStream+import java.nio.ByteBuffer+import java.util.concurrent.ArrayBlockingQueue+import java.util.concurrent.TimeUnit++private const val TAG = "CastPlayback"++/**+ * YouPipe's cast session: where the video goes, and where the audio goes.+ *+ * An object because the two halves live in different places and both have to reach it. The `Surface`+ * is consumed by `VideoPlayer`, which hands it to the `MediaController`; the PCM is produced inside+ * [PlaybackService]'s audio sink, which has no reference to any of the UI. They are in the same process+ * - `PlaybackService` is a `MediaSessionService` in this app - so a singleton is enough and no second+ * IPC hop is needed.+ *+ * **The reason a URL is not handed over instead.** YouPipe's stream URLs are usually synthetic+ * (`sabr://<videoId>?v=<itag>`), resolvable only in-process by `SabrNgDashMediaSource` with a PO token+ * minted through a WebView, and the receiver is deliberately on a LAN with no internet. So what crosses+ * to the TV is pixels and PCM, which is also why ExoPlayer keeps decoding and keeps its transport+ * controls: only the render target changes.+ */+object CastPlayback {++    /** Where the cast is. */+    sealed interface State {++        /** Playing locally. */+        data object Idle : State++        /** The picker is up, or the session is being negotiated with the TV. */+        data object Connecting : State++        /**+         * On the TV. [surface] is what the player must render into, and it belongs to Cast - it must+         * not be released here, which is what would break the *next* cast rather than this one.+         */+        data class Casting(+            val surface: Surface,+            val receiverName: String,+            val width: Int,+            val height: Int,+        ) : State+    }++    private val _state = MutableStateFlow<State>(State.Idle)+    val state: StateFlow<State> = _state.asStateFlow()++    private var client: CastClient? = null++    fun support(context: Context): CastClient.Support = CastClient(context).support()++    /** True while the picker or the negotiation is in flight, so a second tap does nothing. */+    fun markConnecting() {+        _state.value = State.Connecting+    }++    /**+     * Open a session for a [width] x [height] frame and start the audio tap.+     *+     * The geometry is a request: Cast clamps it to the TV's decoder limits and to this phone's own+     * encoder, and [State.Casting] carries what was actually granted.+     *+     * Returns the failure rather than throwing, because every caller here is a button and every+     * failure is a message.+     */+    suspend fun open(context: Context, width: Int, height: Int): CastException? {+        close()+        _state.value = State.Connecting+        val newClient = CastClient(context)+        return try {+            val session = newClient.openSession(width, height, wantAudio = true)+            client = newClient+            newClient.onEnded = { reason ->+                Log.i(TAG, "the cast session ended (reason $reason)")+                close()+            }+            CastAudioTap.attach(session.audio)+            _state.value = State.Casting(+                surface = session.surface,+                receiverName = session.receiverName,+                width = session.width,+                height = session.height,+            )+            null+        } catch (e: CastException) {+            newClient.close()+            _state.value = State.Idle+            e+        }+    }++    /** Back to playing locally. Idempotent. */+    fun close() {+        CastAudioTap.detach()+        client?.close()+        client = null+        _state.value = State.Idle+    }+}++/**+ * The PCM tap, as a `TeeAudioProcessor.AudioBufferSink`.+ *+ * Sits in `PlaybackService`'s audio-sink processor chain, so it sees the decoded samples on their way+ * to the speaker. Local output is muted with `volume = 0f` rather than by stopping the renderer,+ * because volume is applied in the sink *after* the processor chain - the tap still sees full-scale+ * PCM.+ *+ * **Never blocks the audio thread.** `handleBuffer` runs on the playback thread, and a direct write+ * into a full pipe would stall decoding - which is exactly what happens if the reader on the Cast side+ * stops. So buffers go into a bounded queue and a writer thread drains it; when the queue is full the+ * oldest buffer is dropped, which costs a few milliseconds of audio rather than the whole playback.+ */+@OptIn(UnstableApi::class)+object CastAudioTap : TeeAudioProcessor.AudioBufferSink {++    /** ~0.2 s of 20 ms buffers: long enough to ride out a scheduling hiccup, short enough not to lag. */+    private const val QUEUE_CAPACITY = 16++    private const val ENCODING_PCM_16BIT = android.media.AudioFormat.ENCODING_PCM_16BIT++    @Volatile+    private var out: FileOutputStream? = null++    @Volatile+    private var pipe: ParcelFileDescriptor? = null++    private var writer: Thread? = null++    private val queue = ArrayBlockingQueue<ByteArray>(QUEUE_CAPACITY)++    /** The format the processor chain is handing us, from the last [flush]. */+    @Volatile+    private var sampleRate = CastContract.AUDIO_SAMPLE_RATE++    @Volatile+    private var channelCount = CastContract.AUDIO_CHANNELS++    @Volatile+    private var supported = false++    /** Start writing into [audio]'s pipe. Null means the session has no audio; the tap stays off. */+    fun attach(audio: ParcelFileDescriptor?) {+        detach()+        if (audio == null) return+        pipe = audio+        out = FileOutputStream(audio.fileDescriptor)+        writer = Thread({ drain() }, "cast-pcm-writer").apply {+            isDaemon = true+            start()+        }+    }++    fun detach() {+        val thread = writer+        writer = null+        out = null+        thread?.interrupt()+        queue.clear()+        runCatching { pipe?.close() }+        pipe = null+    }++    override fun flush(sampleRateHz: Int, channelCount: Int, encoding: Int) {+        sampleRate = sampleRateHz+        this.channelCount = channelCount+        // Float output would need a different conversion and is off by default; anything other than+        // interleaved 16-bit is refused rather than sent as noise.+        supported = encoding == ENCODING_PCM_16BIT && sampleRateHz > 0 && channelCount > 0+        if (!supported) {+            Log.w(TAG, "cannot tap audio at ${sampleRateHz}Hz, $channelCount ch, encoding $encoding")+        }+        queue.clear()+    }++    override fun handleBuffer(buffer: ByteBuffer) {+        if (out == null || !supported) return+        val converted = toContractFormat(buffer) ?: return+        // Drop the oldest rather than block: this is the audio thread.+        if (!queue.offer(converted)) {+            queue.poll()+            queue.offer(converted)+        }+    }++    private fun drain() {+        while (!Thread.currentThread().isInterrupted) {+            val chunk = try {+                queue.poll(100, TimeUnit.MILLISECONDS)+            } catch (_: InterruptedException) {+                return+            } ?: continue+            val stream = out ?: return+            try {+                stream.write(chunk)+            } catch (e: Exception) {+                // The Cast side closed the pipe; there is nothing to recover and nothing to say to+                // the user, because the session teardown already will.+                Log.i(TAG, "the PCM pipe closed", e)+                return+            }+        }+    }++    /**+     * Whatever the decoder produced, as 48 kHz stereo 16-bit little-endian.+     *+     * Opus - which is what YouPipe plays almost always - is already 48 kHz stereo, so the common path+     * is a straight copy. The conversions exist for the AAC fallback, which is often 44.1 kHz: without+     * them that video would cast with silent audio and nothing to indicate why.+     */+    private fun toContractFormat(buffer: ByteBuffer): ByteArray? {+        val remaining = buffer.remaining()+        if (remaining <= 0) return null+        val bytes = ByteArray(remaining)+        // Read a duplicate: TeeAudioProcessor passes this same buffer on to the sink afterwards, so+        // consuming it here would silence local playback and, worse, the rest of the chain.+        buffer.duplicate().get(bytes)+        if (sampleRate == CastContract.AUDIO_SAMPLE_RATE &&+            channelCount == CastContract.AUDIO_CHANNELS+        ) {+            return bytes+        }+        val frames = remaining / (2 * channelCount)+        if (frames == 0) return null+        val outFrames = (frames.toLong() * CastContract.AUDIO_SAMPLE_RATE / sampleRate).toInt()+        if (outFrames == 0) return null+        val result = ByteArray(outFrames * 2 * CastContract.AUDIO_CHANNELS)+        for (frame in 0 until outFrames) {+            // Nearest source frame. Resampling per buffer rather than continuously leaves a sub-sample+            // discontinuity at each boundary, which is inaudible next to the alternative of no audio.+            val source = (frame.toLong() * frames / outFrames).toInt().coerceAtMost(frames - 1)+            val base = source * 2 * channelCount+            val left = sampleAt(bytes, base)+            val right = if (channelCount >= 2) sampleAt(bytes, base + 2) else left+            val target = frame * 4+            result[target] = (left and 0xFF).toByte()+            result[target + 1] = (left shr 8 and 0xFF).toByte()+            result[target + 2] = (right and 0xFF).toByte()+            result[target + 3] = (right shr 8 and 0xFF).toByte()+        }+        return result+    }++    /** One little-endian 16-bit sample, as its raw bits. */+    private fun sampleAt(bytes: ByteArray, offset: Int): Int {+        if (offset + 1 >= bytes.size) return 0+        return (bytes[offset].toInt() and 0xFF) or (bytes[offset + 1].toInt() shl 8)+    }+}
youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayer.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayer.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayer.ktindex b58287254c..73d7ca146d 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayer.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayer.kt@@ -93,6 +93,7 @@ import com.vayunmathur.youpipe.R import com.vayunmathur.youpipe.data.HistoryVideo import com.vayunmathur.youpipe.findActivity import com.vayunmathur.youpipe.rememberIsInPipMode+import com.vayunmathur.youpipe.platform.CastPlayback import com.vayunmathur.youpipe.util.PlaybackService import com.vayunmathur.youpipe.util.YouPipeViewModel import kotlinx.coroutines.delay@@ -103,6 +104,15 @@ import androidx.compose.foundation.Canvas import androidx.compose.runtime.collectAsState import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size+import androidx.activity.compose.rememberLauncherForActivityResult+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.IconCast+import com.vayunmathur.library.ui.IconCastConnected+import com.vayunmathur.library.ui.ExternalIntents+import com.vayunmathur.library.util.AppMessages+import com.vayunmathur.sdk.cast.CastClient+import com.vayunmathur.sdk.cast.CastContract+import com.vayunmathur.sdk.cast.CastPickerContract  @OptIn(UnstableApi::class) @Composable@@ -373,6 +383,53 @@ fun VideoPlayer(     val isPipMode = rememberIsInPipMode()     val scope = rememberCoroutineScope() +    // ---- casting ----+    // Cast state lives beside the transport state because that is where VideoPlayer keeps everything+    // else about this one player - but in a singleton rather than a `remember`, since the PCM half of+    // the session is produced inside PlaybackService's audio sink, which has no reference to any of+    // this.+    val castState by CastPlayback.state.collectAsState()+    val isCasting = castState is CastPlayback.State.Casting+    // Resolved here rather than inside the callbacks: reading resources off a Context in a composable+    // misses configuration changes, and lint says so.+    val castFailedMessage = stringResource(R.string.cast_failed)+    val castInstallMessage = stringResource(R.string.cast_install_prompt)+    val castUpdateMessage = stringResource(R.string.cast_update_prompt)+    val castPicker = rememberLauncherForActivityResult(CastPickerContract()) { picked ->+        if (!picked) {+            // Backed out, or pairing failed. Nothing should change in the player.+            CastPlayback.close()+            return@rememberLauncherForActivityResult+        }+        scope.launch {+            // 1080 tall in the video's own shape: the receiver letterboxes, so the aspect ratio is+            // ours to choose, and Cast clamps whatever the TV cannot decode.+            val requestedWidth = (CAST_REQUEST_HEIGHT * aspectRatio).toInt().coerceAtLeast(2)+            if (CastPlayback.open(context, requestedWidth, CAST_REQUEST_HEIGHT) != null) {+                AppMessages.show(castFailedMessage)+            }+        }+    }+    // Moving playback is one call. ExoPlayer keeps decoding and keeps its transport controls, so play,+    // pause and seek still work and still control the remote picture; only the render target changes.+    // Local audio is muted with volume rather than by stopping the renderer, because volume is applied+    // in the sink *after* the processor chain - so CastAudioTap still sees full-scale PCM.+    LaunchedEffect(controller, castState) {+        val player = controller ?: return@LaunchedEffect+        val casting = castState as? CastPlayback.State.Casting+        if (casting != null) {+            player.setVideoSurface(casting.surface)+            player.volume = 0f+        } else {+            player.volume = 1f+        }+    }+    DisposableEffect(Unit) {+        // Leaving the video ends the cast: there is one video output and it cannot follow the user to+        // another screen.+        onDispose { CastPlayback.close() }+    }+     // When paused, keep controls visible (no auto-hide). When playing resumes, re-show and start timer.     LaunchedEffect(isPlaying) {         if (isPlaying) {@@ -387,7 +444,8 @@ fun VideoPlayer(     LaunchedEffect(         isControlsVisible, isPlaying, keepControlsVisible, isLocked, isDragging,         isVideoMenuExpanded, isLanguageMenuExpanded, isCaptionMenuExpanded,-        isSpeedMenuExpanded, isChapterMenuVisible, isPipMode, controlsInteractionTick+        isSpeedMenuExpanded, isChapterMenuVisible, isPipMode, controlsInteractionTick,+        isCasting     ) {         if (!isControlsVisible) return@LaunchedEffect         if (keepControlsVisible) return@LaunchedEffect@@ -396,6 +454,9 @@ fun VideoPlayer(         if (isDragging) return@LaunchedEffect         if (isVideoMenuExpanded || isLanguageMenuExpanded || isCaptionMenuExpanded || isSpeedMenuExpanded || isChapterMenuVisible) return@LaunchedEffect         if (isPipMode) return@LaunchedEffect+        // While casting there is no picture here to get out of the way of, and the only way to stop is+        // a button in these controls.+        if (isCasting) return@LaunchedEffect         delay(CONTROLS_AUTO_HIDE_DELAY_MS)         isControlsVisible = false     }@@ -472,11 +533,22 @@ fun VideoPlayer(             Modifier.fillMaxHeight().aspectRatio(aspectRatio)         }         controller?.let { player ->-            PlayerSurface(-                player = player,-                modifier = playerModifier.align(Alignment.Center),-                surfaceType = SURFACE_TYPE_TEXTURE_VIEW-            )+            // While casting there is no local picture: there is one video output and it is the TV, which+            // is also what the user expects to see when they have just cast something.+            val casting = castState as? CastPlayback.State.Casting+            if (casting != null) {+                CastingPanel(+                    receiverName = casting.receiverName,+                    onStop = { CastPlayback.close() },+                    modifier = Modifier.fillMaxSize(),+                )+            } else {+                PlayerSurface(+                    player = player,+                    modifier = playerModifier.align(Alignment.Center),+                    surfaceType = SURFACE_TYPE_TEXTURE_VIEW+                )+            }         } ?: Box(modifier = Modifier.fillMaxSize().background(Color.Black))          if (cues.isNotEmpty()) {@@ -584,6 +656,38 @@ fun VideoPlayer(                         }                     } +                    // Always visible, whether or not Cast is installed: an icon that appears only when+                    // it would work is an icon nobody discovers.+                    IconButton(+                        onClick = {+                            controlsInteractionTick+++                            when (CastPlayback.support(context)) {+                                CastClient.Support.NOT_INSTALLED -> {+                                    AppMessages.show(castInstallMessage)+                                    ExternalIntents.openAppListing(context, CastContract.CAST_PACKAGE)+                                }+                                CastClient.Support.NEEDS_UPDATE -> {+                                    AppMessages.show(castUpdateMessage)+                                    ExternalIntents.openAppListing(context, CastContract.CAST_PACKAGE)+                                }+                                CastClient.Support.READY ->+                                    if (isCasting) {+                                        CastPlayback.close()+                                    } else {+                                        CastPlayback.markConnecting()+                                        castPicker.launch(Unit)+                                    }+                            }+                        },+                        modifier = Modifier.background(Color.Black.copy(alpha = 0.5f), RoundedCornerShape(4.dp)).size(32.dp)+                    ) {+                        if (isCasting) {+                            IconCastConnected(tint = Color.White, modifier = Modifier.size(20.dp))+                        } else {+                            IconCast(tint = Color.White, modifier = Modifier.size(20.dp))+                        }+                    }+                     if (segments.isNotEmpty()) {                         IconButton(                             onClick = { isChapterMenuVisible = true },@@ -836,6 +940,44 @@ fun VideoPlayer( private const val HISTORY_UPSERT_INTERVAL_MS = 5000L private const val CONTROLS_AUTO_HIDE_DELAY_MS = 2000L +/**+ * The frame height asked of Cast, with the width taken from the video's own aspect ratio.+ *+ * A request, not a decision: Cast clamps it to what the TV reported it can decode and to what this+ * phone's encoder will take, and answers with the real numbers.+ */+private const val CAST_REQUEST_HEIGHT = 1080++/**+ * What the player shows once the video is on the TV.+ *+ * There is one video output and it is now the TV, so there is nothing to draw here - and this is also+ * what the user expects to see after casting something, rather than the same video twice.+ */+@Composable+private fun CastingPanel(+    receiverName: String,+    onStop: () -> Unit,+    modifier: Modifier = Modifier,+) {+    Column(+        modifier = modifier.background(Color.Black),+        horizontalAlignment = Alignment.CenterHorizontally,+        verticalArrangement = Arrangement.Center,+    ) {+        IconCastConnected(tint = Color.White, modifier = Modifier.size(48.dp))+        Text(+            text = stringResource(R.string.cast_playing_on, receiverName),+            color = Color.White,+            style = MaterialTheme.typography.titleMedium,+            modifier = Modifier.padding(top = 12.dp),+        )+        Button(onClick = onStop, modifier = Modifier.padding(top = 16.dp)) {+            Text(stringResource(R.string.cast_stop))+        }+    }+}+ /** Formats a tempo multiplier for display: whole values as "2", fractional as "1.5". */ private fun formatTempo(speed: Float): String {     val rounded = Math.round(speed * 100f) / 100f
youpipe/src/main/java/com/vayunmathur/youpipe/util/PlaybackService.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/util/PlaybackService.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/util/PlaybackService.ktindex 9a96a03617..03b3b0a07b 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/util/PlaybackService.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/util/PlaybackService.kt@@ -20,6 +20,7 @@ import androidx.media3.session.MediaSession import androidx.media3.session.MediaSessionService import com.google.common.util.concurrent.Futures import com.google.common.util.concurrent.ListenableFuture+import com.vayunmathur.youpipe.platform.CastAudioTap import com.vayunmathur.youpipe.util.sabr.LocalDomPoTokenProvider import com.vayunmathur.youpipe.util.sabr.SabrNgDashMediaSource import com.vayunmathur.youpipe.util.sabr.SabrNgSessionStore@@ -179,6 +180,30 @@ class PlaybackService : MediaSessionService() {         } catch (_: Exception) {}          val renderersFactory = object : androidx.media3.exoplayer.DefaultRenderersFactory(this) {+            /**+             * Insert the cast PCM tap into the audio sink's processor chain.+             *+             * This is the hook the cast path needs: `CastAudioTap` sees the decoded samples on their+             * way to the speaker, so casting does not have to re-decode anything. It costs nothing+             * when no cast session is open - the tap has no output stream and drops the buffer - and+             * local muting still works, because `volume` is applied in the sink *after* the chain, so+             * the tap sees full-scale PCM either way.+             */+            override fun buildAudioSink(+                context: android.content.Context,+                enableFloatOutput: Boolean,+                enableAudioTrackPlaybackParams: Boolean+            ): androidx.media3.exoplayer.audio.AudioSink =+                androidx.media3.exoplayer.audio.DefaultAudioSink.Builder(context)+                    .setEnableFloatOutput(enableFloatOutput)+                    .setEnableAudioTrackPlaybackParams(enableAudioTrackPlaybackParams)+                    .setAudioProcessors(+                        arrayOf(+                            androidx.media3.exoplayer.audio.TeeAudioProcessor(CastAudioTap),+                        )+                    )+                    .build()+             @OptIn(ExperimentalApi::class)             override fun buildTextRenderers(                 context: android.content.Context,
youpipe/src/main/res/values/strings.xml
diff --git a/youpipe/src/main/res/values/strings.xml b/youpipe/src/main/res/values/strings.xmlindex 5855aab6bc..3e23297ed7 100644--- a/youpipe/src/main/res/values/strings.xml+++ b/youpipe/src/main/res/values/strings.xml@@ -295,4 +295,18 @@     <string name="label_keep_controls_visible">Keep player controls visible</string>     <!-- Description for keep-controls toggle: controls stay on screen rather than hiding after inactivity. Accessibility feature -->     <string name="label_keep_controls_visible_description">Controls stay on screen instead of hiding after 2 seconds. Useful for accessibility.</string>++    <!-- Casting the video to a TV through the MA Cast app. -->+    <!-- Content description for the cast button in the player controls -->+    <string name="cast_to_tv">Cast to a television</string>+    <!-- Shown where the video was, once it is playing on the TV instead. %1$s is the TV's name -->+    <string name="cast_playing_on">Playing on %1$s</string>+    <!-- Button under the "playing on TV" panel -->+    <string name="cast_stop">Stop casting</string>+    <!-- Shown when the Cast app is not installed and the store listing is being opened -->+    <string name="cast_install_prompt">MA Cast is not installed. Opening its listing so you can install it.</string>+    <!-- Shown when the installed Cast app is too old to stream app content -->+    <string name="cast_update_prompt">MA Cast is too old to play videos on your TV. Opening its listing so you can update it.</string>+    <!-- Shown when the TV would not start a stream -->+    <string name="cast_failed">Could not start casting to your TV</string> </resources>