@siteed/expo-audio-stream 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +5 -33
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -37,6 +37,8 @@ Add the plugin to your app.json like so:
37
37
  }
38
38
  ```
39
39
 
40
+ Make sure to run `npx expo prebuild` after adding the plugin to your app.json file.
41
+
40
42
  ## Usage
41
43
 
42
44
  The `example/` folder contains a fully functional React Native application that demonstrates how to integrate and use the `@siteed/expo-audio-stream` library in a real-world scenario. This sample application includes features such as starting and stopping audio recordings, handling permissions, and processing live audio data.
@@ -47,7 +49,7 @@ The `example/` folder contains a fully functional React Native application that
47
49
  import {
48
50
  useAudioRecorder,
49
51
  AudioStreamResult,
50
- } from 'expo-audio-stream';
52
+ } from '@siteed/expo-audio-stream';
51
53
 
52
54
  export default function App() {
53
55
  const { startRecording, stopRecording, duration, size, isRecording } = useAudioRecorder({
@@ -92,41 +94,11 @@ export default function App() {
92
94
 
93
95
  The library also exposes an `addAudioEventListener` function that provides an `AudioEventPayload` object that you can subscribe to:
94
96
  ```tsx
95
- export interface AudioEventPayload {
96
- encoded?: string,
97
- buffer?: Blob,
98
- fileUri: string,
99
- from: number,
100
- deltaSize: number,
101
- totalSize: number,
102
- mimeType: string;
103
- streamUuid: string,
104
- };
97
+ import { addAudioEventListener } from '@siteed/expo-audio-stream';
105
98
 
106
99
  useEffect(() => {
107
100
  const subscribe = addAudioEventListener(async ({fileUri, deltaSize, totalSize, from, streamUuid, encoded, mimeType, buffer}) => {
108
- log(`Received audio event:`, {fileUri, deltaSize, totalSize, mimeType, from, streamUuid, encodedLength: encoded?.length})
109
- if(deltaSize > 0) {
110
- // Coming from native ( ios / android ) otherwise buffer is set
111
- if(Platform.OS !== 'web') {
112
- // Read the audio file as a base64 string for comparison
113
- try {
114
- // convert encoded string to binary data
115
- const binaryData = atob(encoded);
116
- const content = new Uint8Array(binaryData.length);
117
- for (let i = 0; i < binaryData.length; i++) {
118
- content[i] = binaryData.charCodeAt(i);
119
- }
120
- const audioBlob = new Blob([content], { type: mimeType });
121
- console.info(`Received audio blob:`, audioBlob);
122
- } catch (error) {
123
- console.error('Error reading audio file:', error);
124
- }
125
- } else if(buffer) {
126
- // Coming from web
127
- console.info(`Received audio buffer:`, buffer)
128
- }
129
- }
101
+ log(`Received audio event:`, {fileUri, deltaSize, totalSize, mimeType, from, streamUuid, encodedLength: encoded?.length, bufferLength: buffer?.length})
130
102
  });
131
103
  return () => subscribe.remove();
132
104
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siteed/expo-audio-stream",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "stream audio crossplatform",
5
5
  "license": "MIT",
6
6
  "main": "build/index.js",