4 releases

0.0.4 Feb 15, 2023
0.0.3 Jan 24, 2023
0.0.2 Jan 24, 2023
0.0.1 Jan 24, 2023

#834 in WebAssembly

MIT/Apache

185KB
1.5K SLoC

Plyr-rs

crates.io docs.rs

Rust bindings for Plyr.Please check the official plyr page for more details.

Installation

Specify it as a dependency in Cargo.toml

[dependencies]
plyr = { git = "https://github.com/deepgreenAN/plyr-rs"}

Usage

Html or Rsx and CSS

See the official page or simple example for how to write in html or rsx and css.

Rust

Give the css selector as an argument as follows,

use plyr::Plyr;

let player = Plyr::new("#player");

or web_sys::HtmlElement.

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::<HtmlElement>());

If you want to pass options to the constructor, modify the features.

[dependencies]
plyr = { git = "https://github.com/deepgreenAN/plyr-rs", features = ["options"]}
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.

<script src="https://cdn.plyr.io/3.7.3/plyr.polyfilled.js"></script>
[dependencies]
plyr = { git = "https://github.com/deepgreenAN/plyr-rs", features = ["cdn"]}

Examples

Check examples directory for other examples.

Dependencies

~6.5–9MB
~173K SLoC