@@ -11,9 +11,11 @@ import AudioPlayIcon from "../icons/AudioPlayIcon"
11
11
import AudioNextIcon from "../icons/AudioNextIcon"
12
12
import AudioPauseIcon from "../icons/AudioPauseIcon"
13
13
import { FullScreenContext } from "./FullScreenContext" ;
14
+ import AudioPlayerContext from './AudioPlayerContext' ;
15
+ import audioManager from '../components/audioManager'
14
16
import "../styles/ControlCenter.scss"
15
17
import { useState , useRef , useContext , useEffect } from "react"
16
- import React from "react"
18
+
17
19
export default function ControlCenter ( ) {
18
20
19
21
const connectivity = [
@@ -22,25 +24,27 @@ const connectivity =[
22
24
{ id :3 , Icon1 : < AirDropIcon /> , textbig : "Airdrop" , textsmall : "Contacts Only" } ,
23
25
]
24
26
25
- const audioList = [
26
- {
27
- src : "audio1.mp3 " ,
28
- title : "This is helpful while coding pt.1" ,
29
- description : "Lo-Fi लो-फाई (siddharth's playlist)"
30
- } ,
31
- {
32
- src : "audio2.mp3 " ,
33
- title : "This is helpful while coding pt.2" ,
34
- description : "Lo-Fi लो-फाई (siddharth's playlist)"
35
- }
36
- ] ;
37
- const [ currentTrackIndex , setCurrentTrackIndex ] = useState ( 0 ) ;
38
- const [ isPlaying , setIsPlaying ] = useState ( false ) ;
27
+ // const audioList = [
28
+ // {
29
+ // src: "audio1.webm ",
30
+ // title: "This is helpful while coding pt.1",
31
+ // description: "Lo-Fi लो-फाई (siddharth's playlist)"
32
+ // },
33
+ // {
34
+ // src: "audio2.webm ",
35
+ // title: "This is helpful while coding pt.2",
36
+ // description: "Lo-Fi लो-फाई (siddharth's playlist)"
37
+ // }
38
+ // ];
39
+ // const [currentTrackIndex, setCurrentTrackIndex] = useState(0);
40
+ // const [isPlaying, setIsPlaying] = useState(false);
39
41
const [ volume , setVolume ] = useState ( 70 ) ;
40
42
const audioRef = useRef ( null ) ;
41
43
const [ selectedItems , setSelectedItems ] = useState ( { } ) ;
42
44
const [ brightness , setBrightness ] = useState ( 100 ) ;
43
45
const { fullScreenSelected, toggleFullScreen } = useContext ( FullScreenContext ) ;
46
+ const { isPlaying, handlePlayPause, handleNext, currentTrackIndex, audioList } = useContext ( AudioPlayerContext ) ;
47
+
44
48
45
49
const handleVolumeChange = ( e ) => {
46
50
const newVolume = e . target . value ;
@@ -50,22 +54,27 @@ const handleVolumeChange = (e) => {
50
54
}
51
55
} ;
52
56
53
- const handlePlayPause = ( ) => {
54
- if ( audioRef . current ) {
55
- if ( isPlaying ) {
56
- audioRef . current . pause ( ) ;
57
- } else {
58
- audioRef . current . currentTime = 0 ;
59
- audioRef . current . play ( ) ;
60
- }
61
- setIsPlaying ( ! isPlaying ) ;
62
- }
63
- } ;
57
+ // const handlePlayPause = () => {
58
+ // if (audioRef.current) {
59
+ // if (isPlaying) {
60
+ // audioManager.pause();
61
+ // } else {
62
+ // // audioRef.current.currentTime = 0;
63
+ // // audioRef.current.play();
64
+ // audioManager.play(audioList[currentTrackIndex].src);
65
+ // }
66
+ // setIsPlaying(!isPlaying);
67
+ // }
68
+ // };
64
69
65
- const handleNext = ( ) => {
66
- setCurrentTrackIndex ( ( prevIndex ) => ( prevIndex + 1 ) % audioList . length ) ;
67
- setIsPlaying ( false ) ;
68
- } ;
70
+ // const handleNext = () => {
71
+ // // setCurrentTrackIndex((prevIndex) => (prevIndex + 1) % audioList.length);
72
+ // // setIsPlaying(false);
73
+ // const nextIndex = (currentTrackIndex + 1) % audioList.length;
74
+ // setCurrentTrackIndex(nextIndex);
75
+ // audioManager.play(audioList[nextIndex].src);
76
+ // setIsPlaying(true);
77
+ // };
69
78
70
79
const handleLofiWebsite = ( ) => {
71
80
window . open ( "https://lofigirl.com/releases/sleeping-soul/" , "" ) ;
0 commit comments