Skip to main content

player_enter_background_audio

Function player_enter_background_audio 

Source
pub async fn player_enter_background_audio(
    player: State<'_, PlayerStateWrapper>,
    session: State<'_, MediaSessionManagerWrapper>,
    db: State<'_, DatabaseWrapper>,
    item: PlayItemRequest,
    position_seconds: f64,
) -> Result<PlayerStatus, String>
Expand description

Enter background-audio mode: hand playback of the currently-watched video off to the native ExoPlayer audio path so the audio keeps playing while the app is backgrounded/locked, with no client-side video decode (UR-040).

stream_url MUST be an audio-only URL (see get_audio_only_stream_url_for_video). The item is created as MediaType::Audio so it starts an audio session and loads into the native backend with mediaType="audio" — the WebView <video> is torn down on the frontend side, so exactly one audio source is ever active.

This deliberately goes through the queue-based play_item path (NOT a side-channel) so end-of-track lands in on_playback_ended, which already honors the sleep timer (Time/Episodes/EndOfTrack) and drives autoplay-next. The sleep-timer state is intentionally left untouched by the handoff.

TRACES: UR-040 | DR-052 | UT-061, IT-013