Play video in an Android app with Fission

Put a real video beside an observation draft and address its play and pause controls by one stable player ID. Check Android playback rather than only button dispatch.
Android

What you will build

Compose a reference-video screen with independent written notes and test the native player without promising unsupported Android audio policies.
Embed a real network video without autoplay
Address Play and Pause to the same stable video identity
Keep written observations independent of playback state
Check native surface placement, interrupted playback and the Android audio-option boundary
A field-survey app can put a reference clip beside an observation draft. The two pieces have different owners: the native player owns decoding and playback, whilst the component owns the user's unsaved note. Pressing Play must not mark a survey complete or pretend the user has watched the clip.
This example uses a public flower video to demonstrate that interaction. It is not a botanical training course or an app-owned production asset. Replace the source and accompanying explanation with material you have rights to distribute; meaningful instructional audio also needs captions or an equivalent accessible transcript. A semantic label identifies the surface but does not provide either.
Start from a new project (optional)

Create the Android project

Complete Android SDK/NDK setup, then choose an emulator or a phone.
cargo install cargo-fission
fission init harbour-plant-survey
cd harbour-plant-survey
fission add-target android --project-dir .
cargo add serde_yaml
Keep the generated src/main.rs. The shared library below launches this screen on Android, desktop and Web; the preview does not substitute a different application.

Run the finished example

fission run --target android --project-dir .

1. Address one player from both controls

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"}
Start and pause the clip, then edit the observation. Pausing must preserve the note. The browser uses its real video implementation and the same network URL; a functioning browser preview does not qualify Android's decoding, surface placement or audio behaviour.
Show the app preview
Hide the app preview

2. Test the video, not only its buttons

cargo test
fission doctor android --project-dir .
fission devices --project-dir .
adb devices -l
fission run --target android --device <adb-serial> --project-dir .
fission test --target android --project-dir .
fission build --target android --project-dir . --release
On the selected device, verify actual moving frames, Pause, resume and completion. Rotate or resize where supported and check that the opaque native surface stays aligned with its controls. The widget is not a canvas texture, so do not assume clipping and compositing behave like ordinary text.
Repeat after interrupting connectivity and after backgrounding the app. A dispatched command is not evidence that the media loaded. Inspect real player errors rather than showing a permanent success label when the source is unavailable. Network media does not work offline merely because the rest of the app does; packaging and validating an owned local source is separate work.
The Android backend currently accepts VideoAudioOptions but does not apply those options when creating its player. Setting VideoAudioOptions::playback() therefore cannot promise Android audio focus, ducking or background service behaviour. Test interruptions on the Android versions you support. Fission's video widget is not a standalone background audio service.
fission test checks the generated host can start. It does not prove codec compatibility, sound, network recovery or that the exact release package was installed.

References

Record player behaviour on an emulator and a physical phone separately. Keep failures and unsupported policies visible in the product rather than translating a successful button dispatch into a playback guarantee.