mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 08:54:13 +00:00
fix: resume audio
This commit is contained in:
parent
cd05704a73
commit
8e4d0531e0
1 changed files with 18 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import { useMemo } from 'react';
|
import { useMemo, useEffect } from 'react';
|
||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
import { BiSolidHeart } from 'react-icons/bi/index';
|
import { BiSolidHeart } from 'react-icons/bi/index';
|
||||||
|
import { Howler } from 'howler';
|
||||||
|
|
||||||
import { useSoundStore } from '@/store';
|
import { useSoundStore } from '@/store';
|
||||||
|
|
||||||
|
|
@ -36,6 +37,22 @@ export function App() {
|
||||||
);
|
);
|
||||||
}, [favorites, categories]);
|
}, [favorites, categories]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const onChange = () => {
|
||||||
|
const { ctx } = Howler;
|
||||||
|
|
||||||
|
if (ctx && !document.hidden) {
|
||||||
|
setTimeout(() => {
|
||||||
|
ctx.resume();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener('visibilitychange', onChange, false);
|
||||||
|
|
||||||
|
return () => document.removeEventListener('visibilitychange', onChange);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const allCategories = useMemo(() => {
|
const allCategories = useMemo(() => {
|
||||||
const favorites = [];
|
const favorites = [];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue