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 seconds(self, seconds: f32) -> Self
pub fn seconds(self, seconds: f32) -> Self
How long it lasts, to show before the recording arrives.
Sourcepub fn loading(self, loading: bool) -> Self
pub fn loading(self, loading: bool) -> Self
Whether the recording is on its way, which holds the button until it arrives.
Sourcepub fn on_request(self, handler: impl Fn() + 'static) -> Self
pub fn on_request(self, handler: impl Fn() + 'static) -> Self
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>) -> Self
pub fn transcript(self, text: impl Into<String>) -> Self
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) -> Self
pub fn on_transcribe(self, handler: impl Fn() + 'static) -> Self
With no transcript, offers a button that asks for one.
Sourcepub fn transcribing(self, transcribing: bool) -> Self
pub fn transcribing(self, transcribing: bool) -> Self
Whether a transcript is on its way, which holds that button.
Sourcepub fn transcript_open(self, open: Binding<bool>) -> Self
pub fn transcript_open(self, open: Binding<bool>) -> Self
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§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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.