From d6b9b72aef48e38024ec675285de188f8accd941 Mon Sep 17 00:00:00 2001 From: samuelOsborne Date: Fri, 2 Feb 2024 11:41:12 +0100 Subject: [PATCH] fix: added load_error event --- dotlottie-ffi/src/dotlottie_player.udl | 1 + dotlottie-ffi/src/dotlottie_player_cpp.udl | 1 + dotlottie-rs/src/dotlottie_player.rs | 25 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/dotlottie-ffi/src/dotlottie_player.udl b/dotlottie-ffi/src/dotlottie_player.udl index 045dcc94..593ca2ad 100644 --- a/dotlottie-ffi/src/dotlottie_player.udl +++ b/dotlottie-ffi/src/dotlottie_player.udl @@ -4,6 +4,7 @@ namespace dotlottie_player { [Trait, WithForeign] interface Observer { void on_load(); + void on_load_error(); void on_play(); void on_pause(); void on_stop(); diff --git a/dotlottie-ffi/src/dotlottie_player_cpp.udl b/dotlottie-ffi/src/dotlottie_player_cpp.udl index ba70ca77..c7cc5307 100644 --- a/dotlottie-ffi/src/dotlottie_player_cpp.udl +++ b/dotlottie-ffi/src/dotlottie_player_cpp.udl @@ -4,6 +4,7 @@ namespace dotlottie_player { [Trait] interface Observer { void on_load(); + void on_load_error(); void on_play(); void on_pause(); void on_stop(); diff --git a/dotlottie-rs/src/dotlottie_player.rs b/dotlottie-rs/src/dotlottie_player.rs index a51a014e..7aeb3369 100644 --- a/dotlottie-rs/src/dotlottie_player.rs +++ b/dotlottie-rs/src/dotlottie_player.rs @@ -7,6 +7,7 @@ use crate::lottie_renderer::{LottieRenderer, LottieRendererError}; pub trait Observer: Send + Sync { fn on_load(&self); + fn on_load_error(&self); fn on_play(&self); fn on_pause(&self); fn on_stop(&self); @@ -629,6 +630,12 @@ impl DotLottiePlayer { self.observers.read().unwrap().iter().for_each(|observer| { observer.on_load(); }); + } else { + self.observers.read().unwrap().iter().for_each(|observer| { + observer.on_load_error(); + }); + + return false; } is_ok @@ -644,6 +651,12 @@ impl DotLottiePlayer { self.observers.read().unwrap().iter().for_each(|observer| { observer.on_load(); }); + } else { + self.observers.read().unwrap().iter().for_each(|observer| { + observer.on_load_error(); + }); + + return false; } is_ok @@ -659,6 +672,12 @@ impl DotLottiePlayer { self.observers.read().unwrap().iter().for_each(|observer| { observer.on_load(); }); + } else { + self.observers.read().unwrap().iter().for_each(|observer| { + observer.on_load_error(); + }); + + return false; } is_ok @@ -674,6 +693,12 @@ impl DotLottiePlayer { self.observers.read().unwrap().iter().for_each(|observer| { observer.on_load(); }); + } else { + self.observers.read().unwrap().iter().for_each(|observer| { + observer.on_load_error(); + }); + + return false; } is_ok