@@ -13,7 +13,7 @@ const AudioPlayer: React.FC<AudioPlayerProps> = ({
1313 const [ currentTrack , setCurrentTrack ] = useState ( 0 ) ;
1414 const [ isLoaded , setIsLoaded ] = useState ( false ) ;
1515
16- // Список фэнтези треков (мемоизированный для оптимизации )
16+ // List of fantasy tracks (memoized for optimization )
1717 const tracks = useMemo (
1818 ( ) => [ `${ process . env . PUBLIC_URL } /audio/forest.ogg` ] ,
1919 [ ]
@@ -29,15 +29,15 @@ const AudioPlayer: React.FC<AudioPlayerProps> = ({
2929 } ) ;
3030
3131 audioRef . current . addEventListener ( 'ended' , ( ) => {
32- // Переключаемся на следующий трек
32+ // Switch to next track
3333 setCurrentTrack ( prev => {
3434 const nextTrack = ( prev + 1 ) % tracks . length ;
3535 return nextTrack >= 0 && nextTrack < tracks . length ? nextTrack : 0 ;
3636 } ) ;
3737 } ) ;
3838
3939 audioRef . current . addEventListener ( 'error' , _e => {
40- // Пробуем следующий трек при ошибке
40+ // Try next track on error
4141 setCurrentTrack ( prev => {
4242 const nextTrack = ( prev + 1 ) % tracks . length ;
4343 return nextTrack >= 0 && nextTrack < tracks . length ? nextTrack : 0 ;
@@ -68,27 +68,27 @@ const AudioPlayer: React.FC<AudioPlayerProps> = ({
6868 }
6969 } , [ currentTrack , tracks ] ) ;
7070
71- // Обновляем громкость при изменении volume
71+ // Update volume when volume prop changes
7272 useEffect ( ( ) => {
7373 if ( audioRef . current ) {
74- audioRef . current . volume = Math . max ( 0 , Math . min ( 1 , volume ) ) ; // Ограничиваем значения от 0 до 1
74+ audioRef . current . volume = Math . max ( 0 , Math . min ( 1 , volume ) ) ; // Limit values from 0 to 1
7575 }
7676 } , [ volume ] ) ;
7777
78- // Управляем воспроизведением
78+ // Control playback
7979 useEffect ( ( ) => {
8080 if ( audioRef . current && isLoaded ) {
8181 if ( isPlaying ) {
8282 audioRef . current . play ( ) . catch ( _error => {
83- // Ошибка воспроизведения - игнорируем
83+ // Playback error - ignore
8484 } ) ;
8585 } else {
8686 audioRef . current . pause ( ) ;
8787 }
8888 }
8989 } , [ isPlaying , isLoaded ] ) ;
9090
91- return null ; // Этот компонент не рендерит ничего видимого
91+ return null ; // This component doesn't render anything visible
9292} ;
9393
9494export default AudioPlayer ;
0 commit comments