tauri_plugin_videoplayer/
lib.rs1use tauri::{
2 plugin::{Builder, TauriPlugin},
3 Manager, Runtime,
4};
5
6pub use models::*;
7
8#[cfg(desktop)]
9mod desktop;
10#[cfg(mobile)]
11mod mobile;
12
13mod commands;
14mod error;
15mod models;
16
17pub use error::{Error, Result};
18
19#[cfg(desktop)]
20use desktop::Videoplayer;
21#[cfg(mobile)]
22use mobile::Videoplayer;
23
24pub trait VideoplayerExt<R: Runtime> {
26 fn videoplayer(&self) -> &Videoplayer<R>;
27}
28
29impl<R: Runtime, T: Manager<R>> crate::VideoplayerExt<R> for T {
30 fn videoplayer(&self) -> &Videoplayer<R> {
31 self.state::<Videoplayer<R>>().inner()
32 }
33}
34
35pub fn init<R: Runtime>() -> TauriPlugin<R> {
37 Builder::new("videoplayer")
38 .invoke_handler(tauri::generate_handler![commands::ping, commands::play_video, commands::force_focus])
39 .setup(|app, api| {
40 #[cfg(mobile)]
41 let videoplayer = mobile::init(app, api)?;
42 #[cfg(desktop)]
43 let videoplayer = desktop::init(app, api)?;
44 app.manage(videoplayer);
45 Ok(())
46 })
47 .build()
48}