1
1
/** @jsxImportSource @emotion /react */
2
2
import { css } from '@emotion/react' ;
3
- import React , { useRef , useState } from 'react' ;
3
+ import React , { useEffect , useRef , useState } from 'react' ;
4
4
import ReactPlayer from 'react-player' ;
5
5
import { ButtonGroup , Button , FormControl } from 'react-bootstrap' ;
6
6
import { IPlayingState } from '../models/Player' ;
@@ -23,21 +23,23 @@ export const MusicPlayer: React.FC<IMusicPlayerProps> = (props) => {
23
23
playingState . currentQueueSong + 1
24
24
) ;
25
25
26
+ useEffect ( ( ) => {
27
+ setInputValue ( playingState . currentQueueSong + 1 ) ;
28
+ } , [ playingState . currentQueueSong ] ) ;
29
+
26
30
useEvent ( 'pausevideo' , ( ) => {
27
31
setIsPlaying ( false ) ;
28
32
} ) ;
29
33
30
34
const onPreviousQueueSong = ( ) => {
31
35
if ( playingState . currentQueueSong < 1 ) return ;
32
36
setCurrentQueueSong ( playingState . currentQueueSong - 1 ) ;
33
- setInputValue ( playingState . currentQueueSong ) ;
34
37
} ;
35
38
36
39
const onNextQueueSong = ( ) => {
37
40
if ( playingState . currentQueueSong === playingState . currentQueue . length - 1 )
38
41
return ;
39
42
setCurrentQueueSong ( playingState . currentQueueSong + 1 ) ;
40
- setInputValue ( playingState . currentQueueSong + 2 ) ;
41
43
} ;
42
44
43
45
const handleInputChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
0 commit comments