mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
printWidth: 100
This commit is contained in:
1 parent
d27aeb3b0e
commit
6f4ee009a9
63 files changed
+602
-223
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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
|
||||
? {
|
||||
|
||||
Reference in new issue
Block a user