pub struct AudioPlayerButton { /* private fields */ }Expand description
A button that plays a recording and stops it, with its progress and, when there is one, a transcript to open. Space and Enter work on the button, as on any.
The app delivers the audio as a SoundClip. It can do it later: with
Self::on_request, the first press asks for it and playing starts when it arrives.
It plays through Sound::speak_clip, so a new recording or
anything else said by the Sound takes its place, and this button goes
back to rest. Progress is by the clock, as the service does not report where it is. The
sound does not stop by itself if the view leaves the screen while playing.
use ravenrs_widgets::{AudioPlayerButton, SoundClip, Ui};
let audio = AudioPlayerButton::new()
.clip(SoundClip::new(vec![0.0; 44_100], 44_100))
.transcript("Your order is ready.");
let mut ui = Ui::new(audio, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl AudioPlayerButton
impl AudioPlayerButton
Sourcepub fn new() -> AudioPlayerButton
pub fn new() -> AudioPlayerButton
A player with nothing to play yet.
Sourcepub fn clip(self, clip: SoundClip) -> AudioPlayerButton
pub fn clip(self, clip: SoundClip) -> AudioPlayerButton
The recording.
Sourcepub fn seconds(self, seconds: f32) -> AudioPlayerButton
pub fn seconds(self, seconds: f32) -> AudioPlayerButton
How long it lasts, to show before the recording arrives.
Sourcepub fn loading(self, loading: bool) -> AudioPlayerButton
pub fn loading(self, loading: bool) -> AudioPlayerButton
Whether the recording is on its way, which holds the button until it arrives.
Sourcepub fn on_request(self, handler: impl Fn() + 'static) -> AudioPlayerButton
pub fn on_request(self, handler: impl Fn() + 'static) -> AudioPlayerButton
Called when someone presses play with no recording here: the app brings it, and it
plays when it arrives through Self::clip. Without this or a clip, the button stays
disabled.
Sourcepub fn transcript(self, text: impl Into<String>) -> AudioPlayerButton
pub fn transcript(self, text: impl Into<String>) -> AudioPlayerButton
What was said, under a button that shows and hides it. Blank text says there is no speech in the recording.
Sourcepub fn on_transcribe(self, handler: impl Fn() + 'static) -> AudioPlayerButton
pub fn on_transcribe(self, handler: impl Fn() + 'static) -> AudioPlayerButton
With no transcript, offers a button that asks for one.
Sourcepub fn transcribing(self, transcribing: bool) -> AudioPlayerButton
pub fn transcribing(self, transcribing: bool) -> AudioPlayerButton
Whether a transcript is on its way, which holds that button.
Sourcepub fn transcript_open(self, open: Binding<bool>) -> AudioPlayerButton
pub fn transcript_open(self, open: Binding<bool>) -> AudioPlayerButton
Keeps whether the transcript is open in the app’s hands. By default it starts closed and is kept here.
Trait Implementations§
Source§impl Clone for AudioPlayerButton
impl Clone for AudioPlayerButton
Source§fn clone(&self) -> AudioPlayerButton
fn clone(&self) -> AudioPlayerButton
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AudioPlayerButton
impl Debug for AudioPlayerButton
Source§impl Default for AudioPlayerButton
impl Default for AudioPlayerButton
Source§fn default() -> AudioPlayerButton
fn default() -> AudioPlayerButton
Auto Trait Implementations§
impl !RefUnwindSafe for AudioPlayerButton
impl !Send for AudioPlayerButton
impl !Sync for AudioPlayerButton
impl !UnwindSafe for AudioPlayerButton
impl Freeze for AudioPlayerButton
impl Unpin for AudioPlayerButton
impl UnsafeUnpin for AudioPlayerButton
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.