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,