Skip to content

A lightweight React Native library for playing raw PCM audio streams on Android and iOS. Perfect for real-time audio streaming, VoIP, or custom audio processing

License

Notifications You must be signed in to change notification settings

AminAllahham/react-native-pcm-player

react-native-pcm-player

A lightweight React Native library for playing raw PCM audio streams on Android and iOS. Perfect for real-time audio streaming, VoIP, or custom audio processing

Installation

npm install react-native-pcm-player

Usage

import { playPCM } from 'react-native-pcm-player';

// ...

socket.on("audio-stream", (data) => {
    try {
      const buffer = Buffer.from(data.streamPCMBase64, "base64");
      const pcmArray = [];

      for (let i = 0; i < buffer.length; i += 2) {
        const sample = buffer.readInt16LE(i);
        pcmArray.push(sample);
      }

      playPCM(pcmArray);
    } catch (error) {
      console.error("Error playing PCM data:", error);
    }
});

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

About

A lightweight React Native library for playing raw PCM audio streams on Android and iOS. Perfect for real-time audio streaming, VoIP, or custom audio processing

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published