pub package License

A flutter plugin for playing raw PCM audio data (16-bit integer and 32-bit float).

Platform Support

Android (Kotlin) iOS (Swift)
minSdkVersion 24 platform :ios, '14.0'
✔️ ✔️


  • Create an instance of the RawSoundPlayer
  final _player = RawSoundPlayer();
  • Initialize the player instance with parameters of bufferSize, nChannels, sampleRate and pcmType
  await _player.initialize(
    // Buffer size of the underlying audio track (Android only)
    bufferSize: 4096 << 3,
    // Number of channels, either 1 or 2
    nChannels: 1,
    // Sample rate for playback in Hz
    sampleRate: 16000,
    // PCM format type, either PCMI16 (16-bit integer) or PCMF32 (32-bit float)
    pcmType: RawSoundPCMType.PCMI16,
  • Start the playback
  await _player.play();
  • Feed the player instance with the raw PCM data
  // Demonstrate how to continuously feed the player until the playback is paused/stopped
  while (_player.isPlaying) {
    await _player.feed(dataBlock);
  • Pause the playback
  // Pause immediately and keep queued buffers
  await _player.pause();
  • Stop the playback
  // Stop immediately and drop queued buffers
  await _player.stop();
  • Release the player instance
  // Remember to release any initialized player instances
  await _player.release();