Yew, navigate from single play video in vec to loadscreen

Dear community.

First I provide you the code which compiles
Yew + Tauri App: main branch

The functioning part, I'm working on now:
in Route::MainMenu your can toggle between demo_videos and then select the choreo_video belonging to that file. It will then Route you to Route::ChoreoVideo

I've created a branch named navToLoadVideo.

Not functioning part
When the selected ChoreoVideo has played once, I want to Route to Route::LoadScreenVideo. But instead it loops like the other videos.

So I created a new #[function_component(SingleVideoPlayer)] with the intention to play one file in the vector and then move to pub fn loadscreen_video(). Then I changed the fn choreo_videos() from beeing a Vec<Video> to just returning -> Video, since I thought it would be easier, and now I'm in trouble.

What I'm really asking is:
How can I modify this code to accept a single file in a vector and then on_ended.emit the loadscreen_video()

#[function_component(SingleVideoPlayer)]
pub fn single_video_player(props: &SingleVideoPlayerProps) -> Html {
    let SingleVideoPlayerProps { video, on_ended } = props.clone();

    let video_ended_callback = Callback::from(move |_| {
        // Call the on_ended callback when the video ends
        on_ended.emit(());
    });

    html! {
        <div>
            <p>{&video.title}</p>
            <video src={format! ("{}", video.url)} autoplay=true onended={video_ended_callback} />
        </div>
    }
}

:man_swimming: I'm out on deep waters... :sweat_smile:

Thanks for any help and contributions to my code.

Have you tried implementing emit for the Video/on_ended type?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.