Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added load_error event #75

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions demo-player/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ impl Observer for DummyObserver2 {
fn on_load(&self) {
println!("on_load2");
}
fn on_load_error(&self) {
println!("on_load_error2");
}
fn on_loop(&self, loop_count: u32) {
println!("on_loop2: {}", loop_count);
}
Expand Down Expand Up @@ -62,6 +65,9 @@ impl Observer for DummyObserver {
fn on_load(&self) {
println!("on_load {} ", self.id);
}
fn on_load_error(&self) {
println!("on_load_error {} ", self.id);
}
fn on_loop(&self, loop_count: u32) {
println!("on_loop {}: {}", self.id, loop_count);
}
Expand Down
1 change: 1 addition & 0 deletions dotlottie-ffi/src/dotlottie_player.udl
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions dotlottie-ffi/src/dotlottie_player_cpp.udl
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
25 changes: 25 additions & 0 deletions dotlottie-rs/src/dotlottie_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading