0
   playbackStatusUpdate(playbackObject)(onPlaybackStatusUpdate);

i saw this code from a project i forked from Github, and i'm confused on the syntax, what does it mean?

below is the full code

export const playbackStatusUpdate =
  (playbackObject) =>
  (next = (status) => console.log({ status })) => {
    if ("setOnPlaybackStatusUpdate" in playbackObject) {
      playbackObject.setOnPlaybackStatusUpdate(next);
    }
  };

export const play =
  (playbackObject, uri, shouldPlay = true) =>
  (next = () => {}) =>
  (onPlaybackStatusUpdate = () => {}) => {
    (async () => {
      try {
        const checkLoading = await sound.current.getStatusAsync();
        const soundObj = await playbackObject?.loadAsync(
          { uri },
          { shouldPlay }
        );
        playbackStatusUpdate(playbackObject)(onPlaybackStatusUpdate);
        next(soundObj);
      } catch (error) {
        console.log(`[Audio Error][play]: ${error?.message}`);
      }
    })();
  };
Preye
  • 1
  • 1
  • 2

0 Answers0