@@ -77,6 +77,9 @@ export class VideoReplayer {
7777 // Initially, only load some videos
7878 this . preloadVideos ( { low : 0 , high : PRELOAD_BUFFER } ) ;
7979
80+ // Show first frame by default
81+ this . showVideo ( this . _videos [ 0 ] ) ;
82+
8083 this . _trackList = this . _attachments . map ( ( { timestamp} , i ) => [ timestamp , i ] ) ;
8184 }
8285
@@ -87,6 +90,12 @@ export class VideoReplayer {
8790
8891 // TODO: only attach these when needed
8992 el . addEventListener ( 'ended' , ( ) => this . handleSegmentEnd ( index ) ) ;
93+ el . addEventListener ( 'loadeddata' , event => {
94+ // Used to correctly set the dimensions of the first frame
95+ if ( this . _currentIndex === undefined && index === 0 ) {
96+ this . _callbacks . onLoaded ( event ) ;
97+ }
98+ } ) ;
9099 el . addEventListener ( 'play' , event => {
91100 if ( index === this . _currentIndex ) {
92101 this . _callbacks . onLoaded ( event ) ;
@@ -200,6 +209,7 @@ export class VideoReplayer {
200209 return ;
201210 }
202211
212+ // TODO: resize video if it changes orientation
203213 video . style . display = 'block' ;
204214 }
205215
@@ -418,14 +428,19 @@ export class VideoReplayer {
418428 public pause ( videoOffsetMs : number ) {
419429 const index = this . _currentIndex ?? 0 ;
420430
431+ // Hide first frame if we seek to a later part of the replay first
432+ if ( videoOffsetMs > 0 ) {
433+ this . hideVideo ( 0 ) ;
434+ }
435+
421436 // Preload videos before and after this index
422437 this . preloadVideos ( {
423438 low : index - PRELOAD_BUFFER ,
424439 high : index + PRELOAD_BUFFER ,
425440 } ) ;
426441
427- // Pause the current video
428- const currentVideo = this . getVideo ( this . _currentIndex ) ;
442+ // Pause the old video
443+ const currentVideo = this . getVideo ( index ) ;
429444 currentVideo ?. pause ( ) ;
430445 this . _timer . stop ( videoOffsetMs ) ;
431446
0 commit comments