@@ -92,9 +92,12 @@ class ListenerPlayer extends React.Component {
9292 Math . abs ( calcPos - data . position ) > 2000 )
9393 ) {
9494 // console.log("not synced");
95- this . setState ( {
96- synced : false ,
97- } , ( ) => this . syncListener ( hostUri , calcPos , hostPlaying , true ) ) ;
95+ this . setState (
96+ {
97+ synced : false ,
98+ } ,
99+ ( ) => this . syncListener ( hostUri , calcPos , hostPlaying )
100+ ) ;
98101 } else {
99102 // console.log("synced");
100103 this . setState ( {
@@ -224,36 +227,33 @@ class ListenerPlayer extends React.Component {
224227 * @param {string } uri spotify track uri
225228 * @param {number } position position in milliseconds
226229 * @param {boolean } playing playing state
227- * @param {boolean } force whether to force playing
228230 */
229- async syncListener ( uri , position , playing , force ) {
231+ async syncListener ( uri , position , playing ) {
230232 if ( uri !== playerStore . uri ) {
231233 await playerStore . newTrack ( uri , position ) ;
232234 console . log ( playing , position , playerStore . position . value ) ;
233235 // defer setting play/pause till after update
234- this . setState (
235- {
236- changeSongCallback : ( ) => {
237- if (
238- playing &&
239- position > playerStore . position &&
240- playerStore . position > 0
241- ) {
242- // if host plays and listener was listening when host paused, then resume and seek. if force then play on force.
243- playerStore . resume ( this . state . parked ) ;
244- } else if ( ! playing ) {
245- // if host pauses, pause
246- playerStore . pause ( this . parked ) ;
247- }
248- } ,
249- }
250- ) ;
236+ this . setState ( {
237+ changeSongCallback : ( ) => {
238+ if (
239+ playing &&
240+ position > playerStore . position &&
241+ playerStore . position > 0
242+ ) {
243+ // if host plays and listener was listening when host paused, then resume and seek. if force then play on force.
244+ playerStore . resume ( this . state . parked ) ;
245+ } else if ( ! playing ) {
246+ // if host pauses, pause
247+ playerStore . pause ( this . parked ) ;
248+ }
249+ } ,
250+ } ) ;
251251 } else {
252252 await playerStore . seek ( position ) ;
253253 // defer setting play/pause till after update
254254 this . setState ( {
255255 changeSongCallback : ( ) => {
256- if ( playing || force ) {
256+ if ( playing ) {
257257 // if host plays and listener was listening when host paused, then resume and seek. if force then play on force.
258258 playerStore . resume ( this . state . parked ) ;
259259 } else if ( ! playing ) {
0 commit comments