zng/audio.rs
1#![cfg(feature = "audio")]
2
3//! Audio service, widgets and other types.
4//!
5//! # Service
6//!
7//! The [`AUDIOS`] service manages audio loading and caching. Audio decoding is
8//! implemented by the view-process, for this reason the service must be
9//! used in a headed app or headless app with renderer, in a headless app without renderer no view-process
10//! is spawned so no audio format will be available.
11//!
12//! The audio service also define security limits, the [`AUDIOS.limits`](fn@AUDIOS::limits)
13//! variable to configure these limits. See [`AudioLimits::default`] for the defaults.
14//!
15//! ```
16//! use zng::{audio, prelude::*};
17//! # fn example() {
18//!
19//! audio::AUDIOS.limits().modify(|l| {
20//! l.allow_uri = audio::UriFilter::allow_host("httpbin.org");
21//! l.max_encoded_len = 1.megabytes();
22//! l.max_decoded_len = 10.megabytes();
23//! }); }
24//! ```
25//!
26//! The example above changes the global limits to allow audio downloads only from an specific host and
27//! only allow audio with sizes less or equal to 1 megabyte and that only expands to up to 10 megabytes
28//! after decoding.
29//!
30//! # Full API
31//!
32//! See [`zng_ext_audio`] for the full audio API.
33
34pub use zng_ext_audio::{
35 AUDIOS, AudioCacheMode, AudioDataFormat, AudioFormat, AudioHash, AudioLimits, AudioMix, AudioOptions, AudioOutput, AudioOutputId,
36 AudioOutputState, AudioSource, AudioSourceFilter, AudioTrack, AudioVar,
37};
38
39#[cfg(feature = "http")]
40pub use zng_ext_audio::UriFilter;