Reorganize audio player component

This commit is contained in:
jeffvli
2022-04-26 19:07:45 -07:00
parent 131090ad6c
commit 5f831fa93f
2 changed files with 10 additions and 10 deletions

View File

@@ -9,7 +9,7 @@ import {
import ReactPlayer, { ReactPlayerProps } from 'react-player';
import { Crossfade, PlayerStatus, Song } from '../../../types';
import { crossfadeHandler, gaplessHandler } from './listenHandlers';
import { crossfadeHandler, gaplessHandler } from './utils/listenHandlers';
interface AudioPlayerProps extends ReactPlayerProps {
status: PlayerStatus;
@@ -134,23 +134,23 @@ const AudioPlayer = (
<>
<ReactPlayer
ref={player1Ref}
volume={volume}
playing={currentPlayer === 1 && status === PlayerStatus.Playing}
url={player1?.streamUrl}
muted={muted}
playing={currentPlayer === 1 && status === PlayerStatus.Playing}
progressInterval={isTransitioning ? 10 : 250}
onProgress={type === 'gapless' ? handleGapless1 : handleCrossfade1}
url={player1?.streamUrl}
volume={volume}
onEnded={handleOnEnded}
onProgress={type === 'gapless' ? handleGapless1 : handleCrossfade1}
/>
<ReactPlayer
ref={player2Ref}
volume={volume}
playing={currentPlayer === 2 && status === PlayerStatus.Playing}
url={player2?.streamUrl}
muted={muted}
playing={currentPlayer === 2 && status === PlayerStatus.Playing}
progressInterval={isTransitioning ? 10 : 250}
onProgress={type === 'gapless' ? handleGapless2 : handleCrossfade2}
url={player2?.streamUrl}
volume={volume}
onEnded={handleOnEnded}
onProgress={type === 'gapless' ? handleGapless2 : handleCrossfade2}
/>
</>
);

View File

@@ -1,7 +1,7 @@
/* eslint-disable no-nested-ternary */
import { Dispatch } from 'react';
import { Crossfade } from '../../../types';
import { Crossfade } from '../../../../types';
export const gaplessHandler = (args: {
nextPlayerRef: any;