From 6aa03d13d9cdf0ada6b2858940c9ef98f79db6bc Mon Sep 17 00:00:00 2001 From: Ara Vardanyan <51611306+ara-vardanyan@users.noreply.github.com> Date: Sat, 20 Apr 2024 17:30:06 -0700 Subject: [PATCH] feat: add pause functionality --- src/index.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index efade0e..d312707 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -22,6 +22,11 @@ interface NowPlayingContext extends Partial> { */ play: (audio: MediaSource | Blob | string, type?: string, uid?: string) => Promise; + /** + * Pauses audio playback at the current position. + */ + pause: () => void; + /** * Resumes audio playback from the current position. */ @@ -105,6 +110,12 @@ const NowPlayingContextProvider = ({ children }: NowPlayingContextInterface) => return player.play(); }; + const pause = () => { + if (!player) return; + + player.pause(); + }; + const stop = () => { if (!player) return; @@ -124,6 +135,7 @@ const NowPlayingContextProvider = ({ children }: NowPlayingContextInterface) => value={{ player, play, + pause, resume, stop, uid,