@@ -8,7 +8,6 @@ import axios from 'axios';
88let audioElement = null ;
99let nextAudioElement = null ;
1010let progressAutoSaveInterval = null ;
11- let lifecycleBound = false ;
1211
1312const getAudioUrl = ( song ) =>
1413 song ?. download_url ?. [ 4 ] ?. link || song ?. download_url ?. [ 3 ] ?. link || '' ;
@@ -41,22 +40,6 @@ export const usePlayerStore = create(
4140 nextAudioElement = nextAudio ;
4241 } ,
4342
44- bindLifecycle : ( ) => {
45- if ( lifecycleBound ) return ;
46- lifecycleBound = true ;
47-
48- const persistNow = ( ) => {
49- try {
50- get ( ) . saveProgress ( ) ;
51- } catch { }
52- } ;
53-
54- window . addEventListener ( 'pagehide' , persistNow ) ;
55- document . addEventListener ( 'visibilitychange' , ( ) => {
56- if ( document . visibilityState === 'hidden' ) persistNow ( ) ;
57- } ) ;
58- } ,
59-
6043 updateTime : ( currentTime ) => set ( { currentTime } ) ,
6144
6245 saveProgress : ( ) => {
@@ -204,7 +187,6 @@ export const usePlayerStore = create(
204187 updateMediaSession,
205188 preloadNextTrack,
206189 startAutoSave,
207- bindLifecycle,
208190 } = get ( ) ;
209191
210192 if ( ! audioElement || ! currentSong || currentSong . id === prevSongId ) {
@@ -222,7 +204,6 @@ export const usePlayerStore = create(
222204
223205 await audioElement . play ( ) ;
224206 startAutoSave ( ) ;
225- bindLifecycle ( ) ;
226207
227208 set ( { isPlaying : true } ) ;
228209 addToHistory ( currentSong , audioElement . currentTime , 'autoplay' ) ;
@@ -321,4 +302,4 @@ export const useIsPlaying = () => usePlayerStore((s) => s.isPlaying);
321302export const usePlaylist = ( ) => usePlayerStore ( ( s ) => s . playlist ) ;
322303export const useVolume = ( ) => usePlayerStore ( ( s ) => s . volume ) ;
323304
324- export { getAudioUrl } ;
305+ export { getAudioUrl } ;
0 commit comments