pub struct WasmStreamingDecoder { /* private fields */ }Implementations§
Source§impl WasmStreamingDecoder
impl WasmStreamingDecoder
Sourcepub fn feed(&mut self, data: &[u8]) -> Result<bool, JsValue>
pub fn feed(&mut self, data: &[u8]) -> Result<bool, JsValue>
feed data to the decoder, call as bytes come in from network
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
stream done?
Sourcepub fn get_info(&self) -> Result<JsValue, JsValue>
pub fn get_info(&self) -> Result<JsValue, JsValue>
Get audio information (available after header is parsed)
Returns null if header hasn’t been parsed yet.
Sourcepub fn decode_available(&mut self) -> Result<Vec<f32>, JsValue>
pub fn decode_available(&mut self) -> Result<Vec<f32>, JsValue>
decode all currently available samples
Sourcepub fn next_frame(&mut self) -> Result<JsValue, JsValue>
pub fn next_frame(&mut self) -> Result<JsValue, JsValue>
Decode the next available frame
Returns interleaved f32 samples for one frame, or null if no frame is ready. This enables true streaming: decode and play frames as they arrive.
Usage pattern:
while (true) {
const samples = decoder.next_frame();
if (samples === null) break; // No more frames ready
playAudio(samples);
}Sourcepub fn available_frames(&self) -> usize
pub fn available_frames(&self) -> usize
how many frames ready to decode
Sourcepub fn current_frame_index(&self) -> usize
pub fn current_frame_index(&self) -> usize
current frame index
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the decoder to initial state
Use this to start decoding a new stream.
Sourcepub fn buffered_bytes(&self) -> usize
pub fn buffered_bytes(&self) -> usize
bytes currently buffered
Trait Implementations§
Source§impl Default for WasmStreamingDecoder
impl Default for WasmStreamingDecoder
Source§impl From<WasmStreamingDecoder> for JsValue
impl From<WasmStreamingDecoder> for JsValue
Source§fn from(value: WasmStreamingDecoder) -> Self
fn from(value: WasmStreamingDecoder) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for WasmStreamingDecoder
impl FromWasmAbi for WasmStreamingDecoder
Source§impl IntoWasmAbi for WasmStreamingDecoder
impl IntoWasmAbi for WasmStreamingDecoder
Source§impl RefFromWasmAbi for WasmStreamingDecoder
impl RefFromWasmAbi for WasmStreamingDecoder
Source§type Anchor = RcRef<WasmStreamingDecoder>
type Anchor = RcRef<WasmStreamingDecoder>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl VectorFromWasmAbi for WasmStreamingDecoder
impl VectorFromWasmAbi for WasmStreamingDecoder
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmStreamingDecoder]>
Source§impl VectorIntoWasmAbi for WasmStreamingDecoder
impl VectorIntoWasmAbi for WasmStreamingDecoder
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmStreamingDecoder]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmStreamingDecoder
impl WasmDescribeVector for WasmStreamingDecoder
impl SupportsConstructor for WasmStreamingDecoder
impl SupportsInstanceProperty for WasmStreamingDecoder
impl SupportsStaticProperty for WasmStreamingDecoder
Auto Trait Implementations§
impl Freeze for WasmStreamingDecoder
impl !RefUnwindSafe for WasmStreamingDecoder
impl Send for WasmStreamingDecoder
impl Sync for WasmStreamingDecoder
impl Unpin for WasmStreamingDecoder
impl !UnwindSafe for WasmStreamingDecoder
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
Mutably borrows from an owned value. Read more
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.