@@ -41,7 +41,7 @@ import stylesheet from './styles';
4141import { Colors } from './theme' ;
4242import FastImage from 'react-native-fast-image' ;
4343
44- let currentPlayingRef : React . RefObject < IWaveformRef > | null = null ;
44+ let currentPlayingRef : React . RefObject < IWaveformRef > | undefined ;
4545const RenderListItem = React . memo (
4646 ( {
4747 item,
@@ -60,8 +60,6 @@ const RenderListItem = React.memo(
6060 const [ isLoading , setIsLoading ] = useState ( true ) ;
6161
6262 const handlePlayStopAction = async ( ) => {
63- console . log ( 'currentPlayingRef' , currentPlayingRef ) ;
64-
6563 let currentPlayer = currentPlayingRef ?. current ;
6664
6765 // If no player or if current player is stopped just start it!
@@ -79,7 +77,7 @@ const RenderListItem = React.memo(
7977 await currentPlayingRef ?. current ?. stopPlayer ( ) ;
8078 }
8179
82- // Start player only when it is a different one!
80+ // Start player when it is a different one!
8381 if ( currentPlayer . playerKey ( ) !== ref ?. current ?. playerKey ( ) ) {
8482 currentPlayingRef = ref ;
8583 await currentPlayingRef . current ?. startPlayer ( {
@@ -123,21 +121,15 @@ const RenderListItem = React.memo(
123121 scrubColor = { Colors . white }
124122 waveColor = { Colors . lightWhite }
125123 candleHeightScale = { 4 }
126- onPlayerStateChange = { state => {
127- setPlayerState ( state ) ;
128- console . log ( `state changed ${ state } ` ) ;
129- } }
124+ onPlayerStateChange = { setPlayerState }
130125 onPanStateChange = { onPanStateChange }
131126 onError = { error => {
132127 console . log ( error , 'we are in example' ) ;
133128 } }
134129 onCurrentProgressChange = { ( currentProgress , songDuration ) => {
135- // console.log(
136- // 'currentProgress ',
137- // currentProgress,
138- // 'songDuration ',
139- // songDuration
140- // );
130+ console . log (
131+ `currentProgress ${ currentProgress } , songDuration ${ songDuration } `
132+ ) ;
141133 } }
142134 onChangeWaveformLoadState = { state => {
143135 setIsLoading ( state ) ;
@@ -204,7 +196,7 @@ const LivePlayerComponent = ({
204196 ref . current ?. stopRecord ( ) . then ( path => {
205197 setList ( prev => [ ...prev , { fromCurrentUser : true , path } ] ) ;
206198 } ) ;
207- currentPlayingRef = null ;
199+ currentPlayingRef = undefined ;
208200 }
209201 } ;
210202
0 commit comments