Crate waterui_media

Crate waterui_media 

Source
Expand description

§WaterUI Media Components

This crate provides media handling and display components for the WaterUI framework. It includes support for images, videos, and Live Photos with a reactive, configurable API.

§Components

  • Photo: Display static images with customizable placeholders
  • Video: Video sources that can be used with VideoPlayer
  • VideoPlayer: Video playback with reactive volume control
  • LivePhoto: Apple Live Photo display with image and video components
  • Media: Unified enum for different media types

§Features

  • Reactive: All components integrate with WaterUI’s reactive system
  • Configurable: Built using WaterUI’s configuration pattern
  • Media Picker: Platform-native media selection (feature: media-picker)
  • Type Safety: Strong typing with URLs and media sources

§Examples

§Basic Photo

use waterui_media::{Photo, url::Url};

let url = Url::parse("https://example.com/image.jpg").unwrap();
let _photo = Photo::new(url);

§Video with Controls

use waterui_core::binding;
use waterui_media::{Video, VideoPlayer, url::Url};

let url = Url::parse("https://example.com/video.mp4").unwrap();
let video = Video::new(url);
let muted = binding(false);
let _player = VideoPlayer::new(video).muted(&muted);

§Unified Media Type

use waterui_media::{Media, live::LivePhotoSource, url::Url};

let image = Media::Image(Url::parse("https://example.com/photo.jpg").unwrap());
let video = Media::Video(Url::parse("https://example.com/video.mp4").unwrap());
let live_photo = Media::LivePhoto(LivePhotoSource::new(
    Url::parse("https://example.com/photo.jpg").unwrap(),
    Url::parse("https://example.com/video.mov").unwrap(),
));
assert!(matches!(image, Media::Image(_)));
assert!(matches!(video, Media::Video(_)));
assert!(matches!(live_photo, Media::LivePhoto(_)));

Re-exports§

pub use live::LivePhoto;
pub use photo::Photo;
pub use video::AspectRatio;
pub use video::Video;
pub use video::VideoConfig;
pub use video::VideoPlayer;
pub use video::VideoPlayerConfig;

Modules§

image
Image view primitives and supporting types.
live
Live Photo components and types.
media_picker
Media picker functionality for platform-native media selection.
photo
Photo components and types.
url
URL types for working with media resources
video
Video components and types.

Structs§

Url
A URL that can represent either a web URL or a local file path.

Enums§

Media
A unified media type that can represent different kinds of media content.