printWidth: 100

This commit is contained in:
Christopher committed 2021-03-02 21:03:06 +01:00
1 parent d27aeb3b0e
commit 6f4ee009a9
63 files changed
+602 -223

No files matched your search

+14 -1
View File
@@ -41,7 +41,20 @@ const useSound = (url: string, options: ISoundOptions = DEFAULT_OPTIONS) => {
}
volume(url, vol);
loop(url, isLoop);
}, [url, vol, isLoop, isMounted, volume, loop, mount, previousUrl, stop, remove, isPlaying, play]);
}, [
url,
vol,
isLoop,
isMounted,
volume,
loop,
mount,
previousUrl,
stop,
remove,
isPlaying,
play,
]);
useEffect(() => {
if (interrupt) {
+41 -38
View File
@@ -26,47 +26,50 @@ export const SoundProvider = ({ children }: { children: React.ReactNode }) => {
soundRefs.current = new Map();
}, []);
const mount = useCallback((url: string, volume: number = 1, loop: boolean = false, autoplay: boolean = false) => {
return new Promise<IMountResponse>((res) => {
if (!soundRefs.current) {
soundRefs.current = new Map();
}
const find = soundRefs.current.get(url);
if (find) {
find.howl.volume(volume);
find.howl.loop(loop);
if (autoplay) {
find.howl.play();
const mount = useCallback(
(url: string, volume: number = 1, loop: boolean = false, autoplay: boolean = false) => {
return new Promise<IMountResponse>((res) => {
if (!soundRefs.current) {
soundRefs.current = new Map();
}
return res({ howl: find.howl, url });
}
const instance = new Howl({
src: url,
loop,
volume,
autoplay,
const find = soundRefs.current.get(url);
if (find) {
find.howl.volume(volume);
find.howl.loop(loop);
if (autoplay) {
find.howl.play();
}
return res({ howl: find.howl, url });
}
const instance = new Howl({
src: url,
loop,
volume,
autoplay,
});
soundRefs.current.set(url, { howl: instance, volume });
instance.once('load', () => {
console.log('ready', instance);
res({ howl: instance, url });
});
const onError = (_id, e) => {
res(null);
console.error('Howler Error \n', e, '\nid: ', _id, '\nsrc: ', url);
};
instance.once('loaderror', onError);
instance.once('playerror', onError);
});
soundRefs.current.set(url, { howl: instance, volume });
instance.once('load', () => {
console.log('ready', instance);
res({ howl: instance, url });
});
const onError = (_id, e) => {
res(null);
console.error('Howler Error \n', e, '\nid: ', _id, '\nsrc: ', url);
};
instance.once('loaderror', onError);
instance.once('playerror', onError);
});
}, []);
},
[],
);
const play = useCallback(
(url: string, volume: number, loop: boolean) => {
+5 -1
View File
@@ -9,7 +9,11 @@ const getPath = {
/**
* Gets the configuration for SoundProvider based on settings and apps
*/
export const getSoundSettings = (type: 'ringtone' | 'notification', settings: IPhoneSettings, app?: string) => {
export const getSoundSettings = (
type: 'ringtone' | 'notification',
settings: IPhoneSettings,
app?: string,
) => {
try {
return app
? {