Skip to main content

Module player_ipc

Module player_ipc 

Source
Expand description

Leptos-side bindings for the screen-app player IPC.

Three responsibilities:

  1. Mirror the Rust-side screen_app::player_session::PlayerStatus payload (kept in sync manually — they must match the Serialize/Deserialize shape on both ends). The link is deliberately plain text: app-ui is a WASM crate and can’t depend on screen-app (Tauri-native), so the type can’t be resolved by rustdoc.
  2. Expose extern "C" thin Rust wrappers around the JS helpers __screenOpen / __screenPlay / __screenPause declared in index.html. Returns are Result<JsValue, JsValue> (catch-style) so the calls degrade to no-ops when running outside Tauri.
  3. install_player_status_listener wires a player-status browser-CustomEvent listener and pushes the parsed payload into a Leptos WriteSignal<PlayerStatus>.

Structs§

PlayerStatus
IPC-stable mirror of screen_app::player_session::PlayerStatus.

Enums§

SessionState
IPC-stable mirror of screen_app::player_session::SessionState (plain-text reference — see the crate-level docs for why). serde(rename_all = "lowercase") matches the Rust-side serialization.

Functions§

convert_file_src
Convert a local file path to an asset-protocol URL the <video> element can load. Returns None when running outside Tauri (the standalone trunk serve browser-only path) — callers can render a placeholder in that case.
duration_seconds
Total duration in seconds. Falls back to 60.0 (matches the PlayerControls component’s own fallback) when not reported.
fraction_ms 🔒
install_player_status_listener
Install a player-status browser-CustomEvent listener.
ms_to_seconds 🔒
position
Position fraction 0.0..=1.0 from elapsed/duration. Returns 0.0 when duration is unknown or zero.
screen_convert_file_src_js
Synchronous Tauri helper: convert a local file path into the asset-protocol URL the webview can load via <video src>. Returns the converted string as a JsValue, or JsValue::UNDEFINED when running outside Tauri.
screen_open
Open a file. Bridge throws if __TAURI__ is unavailable (browser-only trunk serve path) — we ignore the error.
screen_pause
Pause playback.
screen_play
Resume playback.