Skip to content

TheLoloS/SoundContext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SoundContext 🎶

React useContext module for play sounds.

Usage:

Play sound:

  playSounds(String: "name", Loop: true/false)

Play background music Difrent beetwen normal is:

  • You can use it only one time
  • When you reuse playBgSounds() you will stop and pause this music
  playBgSounds(String: "name", Loop: true/false)

Import Context:

  • in main:
import { AudioBlobsProvider } from "./SoundContext";

<AudioBlobsProvider>
   <Components />
</AudioBlobsProvider>
  • in components:
import { useContext } from "react";
import { AudioBlobsContext } from "./SoundContext";

const { playSound, volumeChange, playBgSound } = useContext(
   AudioBlobsContext
);

Add volume component:

{volumeChange}

to edit audio links and names: Go to audioFiles.js and just edit it!

Futures:

  • Load file only one time in load and then use sound for memory
  • Create on onended event for evry sound
  • Add loop functionality
  • You can play unlimitend sounds in this same time
  • Add change volume item

Authors

About

React useContext module for play sounds async

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published