@@ -90,7 +90,7 @@ export default class MemorySource extends AbstractSource {
9090 return record ;
9191 }
9292
93- getNewPlayer = ( logger : Logger , id : PlayPlatformId , opts : PlayerStateOptions ) => new GenericPlayerState ( logger , id , opts )
93+ getNewPlayer = ( logger : Logger , id : PlayPlatformId , opts : PlayerStateOptions ) : AbstractPlayerState => new GenericPlayerState ( logger , id , opts )
9494
9595 setNewPlayer = ( idStr : string , logger : Logger , id : PlayPlatformId , opts : PlayerStateOptions = { } ) => {
9696 this . players . set ( idStr , this . getNewPlayer ( this . logger , id , {
@@ -167,7 +167,17 @@ export default class MemorySource extends AbstractSource {
167167 }
168168 incomingData = relevantDatas [ 0 ] ;
169169
170- const [ currPlay , prevPlay ] = asPlayerStateDataMaybePlay ( incomingData ) ? player . setState ( incomingData . status , incomingData . play ) : player . setState ( undefined , incomingData ) ;
170+ let playerState : PlayerStateDataMaybePlay ;
171+ if ( asPlayerStateDataMaybePlay ( incomingData ) ) {
172+ playerState = incomingData ;
173+ } else {
174+ playerState = { play : incomingData , platformId : getPlatformIdFromData ( incomingData ) } ;
175+ }
176+ if ( playerState . position === undefined && playerState . play !== undefined && playerState . play . meta . trackProgressPosition !== undefined ) {
177+ playerState . position = playerState . play . meta ?. trackProgressPosition ;
178+ }
179+
180+ const [ currPlay , prevPlay ] = player . update ( playerState ) ;
171181 const candidate = prevPlay !== undefined ? prevPlay : currPlay ;
172182 const playChanged = prevPlay !== undefined ;
173183
0 commit comments