A control action needs the identity of its intended player. Give the video a stable explicit ID and obtain its typed controls from that same ID. There is no separate local is_playing flag: changing such a flag would change a label, not make the native player decode or display a frame.
Autoplay remains off. Play and Pause are deliberate actions, and the note is independent of them.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/app.rs","value":"src-app-rs"},{"index":1,"label":"src/translations.rs","value":"src-translations-rs"},{"index":2,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":3,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"},{"index":4,"label":"src/lib.rs","value":"src-lib-rs"},{"index":5,"label":"preview/lib.rs","value":"preview-lib-rs"}]}
{"id":"fission-tabs-1","index":0,"label":"src/app.rs","value":"src-app-rs"}
use fission::prelude::*;
const SAMPLE_VIDEO_URL: &str =
"https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4";
fission_component! {
pub PlantSurveyPlayer<()> {
state { observation: String = String::new() }
}
view(screen, _state, cx) {
let tokens = &cx.view.env().theme.tokens;
let video_width = (cx.view.viewport_size().width - 2.0 * tokens.spacing.l)
.clamp(1.0, 640.0);
let video_id = WidgetId::explicit("plant-survey.growth-reference");
let controls = cx.build.video_controls(video_id);
let video = Video::network(SAMPLE_VIDEO_URL)
.id(video_id)
.size(video_width, video_width * 9.0 / 16.0)
.semantic_label(cx.tr("player.video.label"));
} =>
SafeArea(child: Scroll(child: SemanticsRegion(
identifier: Some("plant-survey.player".to_string()),
label: Some(cx.tr("player.screen.label")),
child: Container(
Column(gap: tokens.spacing.m, children: [
Column(gap: tokens.spacing.xs, children: [
Text(cx.tr("player.app.title"))
.weight(tokens.typography.font_weight_bold),
Text(cx.tr("player.app.subtitle"))
.color(tokens.colors.text_secondary),
]),
Divider(),
Text(cx.tr("player.clip.title"))
.weight(tokens.typography.font_weight_semibold),
Container(video)
.width(video_width)
.height(video_width * 9.0 / 16.0)
.border(tokens.colors.border, 1.0)
.border_radius(tokens.radii.medium),
Row(gap: tokens.spacing.s, wrap: ir_op::FlexWrap::Wrap, children: [
Button(
child: Text(cx.tr("player.action.play")),
key: "play-growth-video",
variant: ButtonVariant::Primary,
on_press: controls.play(),
),
Button(
child: Text(cx.tr("player.action.pause")),
key: "pause-growth-video",
variant: ButtonVariant::Outline,
on_press: controls.pause(),
),
]),
TextInput(
label: Some(cx.tr("player.observation").into()),
helper_text: Some(cx.tr("player.note_scope").into()),
bind: screen.observation, multiline: true,
semantics_identifier: "player.observation".to_owned(),
),
Text(cx.tr("player.scope"))
.color(tokens.colors.text_secondary),
])
)
.padding_all(tokens.spacing.l)
.bg(tokens.colors.surface)
.border(tokens.colors.border, 1.0)
.border_radius(tokens.radii.large),
)))
}
{"id":"fission-tabs-1","index":1,"label":"src/translations.rs","value":"src-translations-rs"}
use std::collections::HashMap;
use fission::prelude::*;
pub fn create_env() -> Env {
let mut env = Env::default();
env.locale = Locale::from("en-US");
for (locale, source) in [
("en-US", include_str!("../i18n/en-US.yaml")),
("es-ES", include_str!("../i18n/es-ES.yaml")),
] {
let messages: HashMap<String, String> =
serde_yaml::from_str(source).expect("valid checked-in translations");
env.i18n.add_bundle(TranslationBundle { locale: Locale::from(locale), messages });
}
env
}
{"id":"fission-tabs-1","index":2,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
player.screen.label: "Plant survey video player"
player.app.title: "Harbour Plant Survey"
player.app.subtitle: "Observe a reference clip"
player.clip.title: "Flower growth-stage sample"
player.video.label: "Flower growth-stage reference video"
player.action.play: "Play video"
player.action.pause: "Pause video"
player.scope: "Browser preview uses an external sample video; use an app-owned source in production."
player.observation: "Observation draft"
player.note_scope: "Local notes only; nothing is saved or submitted."
{"id":"fission-tabs-1","index":3,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
player.screen.label: "Reproductor de vídeo del inventario de plantas"
player.app.title: "Inventario de plantas de Harbour"
player.app.subtitle: "Observar un vídeo de referencia"
player.clip.title: "Muestra de las etapas de crecimiento de una flor"
player.video.label: "Vídeo de referencia de las etapas de crecimiento de una flor"
player.action.play: "Reproducir vídeo"
player.action.pause: "Pausar vídeo"
player.scope: "La vista previa web usa un vídeo externo de muestra; usa una fuente propia en producción."
player.observation: "Borrador de observación"
player.note_scope: "Notas locales; no se guarda ni envía nada."
{"id":"fission-tabs-1","index":4,"label":"src/lib.rs","value":"src-lib-rs"}
pub mod app;
mod translations;
use app::PlantSurveyPlayer;
use fission::prelude::*;
#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
DesktopApp::<(), _>::new(PlantSurveyPlayer::new())
.with_env(translations::create_env())
.run()
}
#[cfg(any(target_os = "android", target_os = "ios"))]
fn mobile_app() -> MobileApp<(), PlantSurveyPlayer> {
let app = MobileApp::<(), _>::new(PlantSurveyPlayer::new())
.with_env(translations::create_env());
#[cfg(all(target_os = "android", debug_assertions))]
let app = app.with_test_control_port(48761);
app
}
#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> { mobile_app().run() }
#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
let _ = mobile_app().run_with_android_app(app_handle);
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
console_error_panic_hook::set_once();
WebApp::<(), _>::new(PlantSurveyPlayer::new())
.with_env(translations::create_env())
.run()
.map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":5,"label":"preview/lib.rs","value":"preview-lib-rs"}
include!("../src/lib.rs");
{"id":"fission-tabs-1"}