diff --git a/example/src/AudioPlayerExample.tsx b/example/src/AudioPlayerExample.tsx
index 0ff0c71ac..70b3badea 100644
--- a/example/src/AudioPlayerExample.tsx
+++ b/example/src/AudioPlayerExample.tsx
@@ -17,6 +17,14 @@ export default function AudioPlayerExample() {
interruptionMode="stop"
/>
+
{
positionMillis: position,
});
},
+ setIsLoopingAsync: mockSetIsLoopAsync,
},
};
},
diff --git a/packages/core/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.ts b/packages/core/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.ts
index ad2a1c51d..7a5762b24 100644
--- a/packages/core/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.ts
+++ b/packages/core/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.ts
@@ -8,6 +8,7 @@ export interface HeadlessAudioPlayerProps extends MediaPlayerProps {
playsInBackground?: boolean;
playsInSilentModeIOS?: boolean;
playThroughEarpieceAndroid?: boolean;
+ isLooping?: boolean;
}
export interface AudioPlayerInterfaceProps {
diff --git a/packages/core/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx b/packages/core/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx
index 48c27bc65..121cf197f 100644
--- a/packages/core/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx
+++ b/packages/core/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx
@@ -31,12 +31,17 @@ const HeadlessAudioPlayer = React.forwardRef<
playThroughEarpieceAndroid = false,
onPlaybackStatusUpdate: onPlaybackStatusUpdateProp,
onPlaybackFinish,
+ isLooping = false,
},
ref
) => {
const [currentSound, setCurrentSound] = React.useState();
const [isPlaying, setIsPlaying] = React.useState(false);
+ React.useEffect(() => {
+ currentSound?.setIsLoopingAsync(isLooping);
+ }, [currentSound, isLooping]);
+
const updateAudioMode = React.useCallback(async () => {
try {
await Audio.setAudioModeAsync({
@@ -71,6 +76,9 @@ const HeadlessAudioPlayer = React.forwardRef<
if (status.isLoaded) {
if (status.didJustFinish) {
+ if (isLooping) {
+ return;
+ }
onPlaybackFinish?.();
}
setIsPlaying(status.isPlaying);