Skip to content

Commit b97fe2f

Browse files
Merge pull request #15 from SimformSolutionsPvtLtd/feat/UNT-T23779
feat(UNT-T23779): added onError callback for static waveform
2 parents 808ebd7 + 0e7d043 commit b97fe2f

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ You can check out the full example at [Example](./example/src/App.tsx).
133133
| waveColor | #545454 ||| string | color of candlestick of waveform |
134134
| scrubColor | #7b7b7b ||| string | color of candlestick of waveform which has played |
135135
| onPlayerStateChange | - ||| ( playerState : PlayerState ) => void | callback function, which returns player state whenever player state changes. |
136-
| onPanStateChange | - ||| ( panMoving : boolean ) => void | callback function which returns boolean indicating whether pan gesture is active or not. |
136+
| onPanStateChange | - ||| ( panMoving : boolean ) => void | callback function which returns boolean indicating whether audio seeking is active or not. |
137137
| onRecorderStateChange | - ||| ( recorderState : RecorderState ) => void | callback function which returns the recorder state whenever the recorder state changes. Check RecorderState for more details |
138+
| onError | - ||| ( error : Error ) => void | callback function which returns the error for static audio waveform |
138139

139140
##### Know more about [ViewStyle](https://reactnative.dev/docs/view-style-props), [PlayerState](#playerstate), and [RecorderState](#recorderstate)
140141

example/src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ const ListItem = React.memo(
9999
waveColor={Colors.gray}
100100
onPlayerStateChange={setPlayerState}
101101
onPanStateChange={onPanStateChange}
102+
onError={error => {
103+
console.log(error, 'we are in example');
104+
}}
102105
/>
103106
</ImageBackground>
104107
</View>

src/components/Waveform/Waveform.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const Waveform = forwardRef<IWaveformRef, IWaveform>((props, ref) => {
4949
onPlayerStateChange,
5050
onRecorderStateChange,
5151
onPanStateChange,
52+
onError,
5253
} = props as StaticWaveform & LiveWaveform;
5354
const viewRef = useRef<View>(null);
5455
const scrollRef = useRef<ScrollView>(null);
@@ -128,6 +129,7 @@ export const Waveform = forwardRef<IWaveformRef, IWaveform>((props, ref) => {
128129
}
129130
} catch (err) {
130131
console.error(err);
132+
(onError as Function)(err);
131133
}
132134
};
133135

@@ -148,9 +150,13 @@ export const Waveform = forwardRef<IWaveformRef, IWaveform>((props, ref) => {
148150
}
149151
}
150152
} catch (err) {
153+
(onError as Function)(err);
151154
console.error(err);
152155
}
153156
} else {
157+
(onError as Function)(
158+
`Can not find waveform for mode ${mode} path: ${path}`
159+
);
154160
console.error(`Can not find waveform for mode ${mode} path: ${path}`);
155161
}
156162
};

src/components/Waveform/WaveformTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface StaticWaveform extends BaseWaveform {
1818
scrubColor?: string;
1919
onPlayerStateChange?: (playerState: PlayerState) => void;
2020
onPanStateChange?: (panMoving: boolean) => void;
21+
onError?: (error: string) => void;
2122
}
2223

2324
export interface LiveWaveform extends BaseWaveform {

0 commit comments

Comments
 (0)