# Plyr-rs [![crates.io](https://img.shields.io/crates/v/plyr.svg)](https://crates.io/crates/plyr) [![docs.rs](https://docs.rs/plyr/badge.svg)](https://docs.rs/plyr) Rust bindings for [Plyr](https://github.com/sampotts/plyr).Please check the official plyr page for more details. ## Installation Specify it as a dependency in `Cargo.toml` ```toml [dependencies] plyr = { git = "https://github.com/deepgreenAN/plyr-rs"} ``` ## Usage ### Html or Rsx and CSS See the official page or [simple example](https://github.com/deepgreenAN/plyr-rs/tree/master/examples/simple-plyr-use) for how to write in html or rsx and css. ### Rust Give the css selector as an argument as follows, ```rust use plyr::Plyr; let player = Plyr::new("#player"); ``` or `web_sys::HtmlElement`. ```rust use gloo_utils::document; use plyr::Plyr; use wasm_bindgen::JsCast; use web_sys::HtmlElement; let player_element = document().query_selector("#player").unwrap().unwrap(); let player = Plyr::new_with_html_element(&player_element.unchecked_into::()); ``` If you want to pass options to the constructor, modify the features. ```toml [dependencies] plyr = { git = "https://github.com/deepgreenAN/plyr-rs", features = ["options"]} ``` ```rust use plyr::options::PlyrOptions; use plyr::Plyr; let _player = Plyr::new_with_options("#player", &PlyrOptions::builder().duration(50.0).build()); ``` ## CDN You can use the cdn for reducing the bundle size of js snippets. ```html ``` ```toml [dependencies] plyr = { git = "https://github.com/deepgreenAN/plyr-rs", features = ["cdn"]} ``` ## Examples - [yew example](https://github.com/deepgreenAN/plyr-rs/tree/master/examples/plyr-yew-example) - [dioxus example](https://github.com/deepgreenAN/plyr-rs/tree/master/examples/plyr-dioxus-example) - [sycamore example](https://github.com/deepgreenAN/plyr-rs/tree/master/examples/plyr-sycamore-example) - [leptos example](https://github.com/deepgreenAN/plyr-rs/tree/master/examples/plyr-leptos-example) - [event listener example](https://github.com/deepgreenAN/plyr-rs/tree/master/examples/event-listener-example) Check [examples](https://github.com/deepgreenAN/plyr-rs/tree/master/examples) directory for other examples.