vorbis_decoder_ffi 0.2.1 copy "vorbis_decoder_ffi: ^0.2.1" to clipboard
vorbis_decoder_ffi: ^0.2.1 copied to clipboard

Ogg Vorbis decoder for Flutter on Android, iOS, and macOS, powered by stb_vorbis through FFI. Decodes in-memory Ogg streams to interleaved 16-bit PCM.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:vorbis_decoder_ffi/vorbis_decoder_ffi.dart';

void main() {
  runApp(const MaterialApp(home: DecodeDemoPage()));
}

class DecodeDemoPage extends StatefulWidget {
  const DecodeDemoPage({super.key});

  @override
  State<DecodeDemoPage> createState() => _DecodeDemoPageState();
}

class _DecodeDemoPageState extends State<DecodeDemoPage> {
  String _status = 'Tap the button to decode assets/sample.ogg';

  Future<void> _decode() async {
    setState(() => _status = 'Decoding…');
    try {
      final bytes = await rootBundle.load('assets/sample.ogg');
      final decoded = await decodeOggAsync(bytes.buffer.asUint8List());
      setState(() {
        _status = 'Decoded assets/sample.ogg\n\n'
            'channels: ${decoded.channels}\n'
            'sample rate: ${decoded.sampleRate} Hz\n'
            'samples/channel: ${decoded.samplesPerChannel}\n'
            'duration: ${decoded.duration.inMilliseconds} ms\n'
            'first samples: ${decoded.pcm.take(8).toList()}';
      });
    } on VorbisDecodeException catch (e) {
      setState(() => _status = 'Decode failed: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('vorbis_decoder_ffi example')),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(24),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(_status, textAlign: TextAlign.center),
              const SizedBox(height: 24),
              FilledButton(
                onPressed: _decode,
                child: const Text('Decode'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
160
points
14
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Ogg Vorbis decoder for Flutter on Android, iOS, and macOS, powered by stb_vorbis through FFI. Decodes in-memory Ogg streams to interleaved 16-bit PCM.

Repository (GitHub)
View/report issues

Topics

#audio #codec #vorbis #ffi

License

MIT (license)

Dependencies

ffi, flutter

More

Packages that depend on vorbis_decoder_ffi

Packages that implement vorbis_decoder_ffi