Skip to content

Commit 747c003

Browse files
committed
fix: make sure that player is available for popout
1 parent ce0797b commit 747c003

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/Video.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from 'react';
33
import loadModules from './esriModules';
44
import './Video.scss';
55
import config from './config';
6+
import { useWindowWidth } from '@react-hook/window-size';
67

78

89
export const getIDFromUrl = url => {
@@ -186,7 +187,10 @@ const Video = ({ GPS_Track_ID, Date_Time, URL, pointsLayer, mapView, testWarning
186187

187188
const popOut = () => {
188189
console.log('popOut');
189-
player.current.pauseVideo();
190+
191+
if (player.current) {
192+
player.current.pauseVideo();
193+
}
190194

191195
const popupWindow = window.open('', 'roadsVideo', 'width=640,height=390,location=0');
192196

@@ -200,7 +204,9 @@ const Video = ({ GPS_Track_ID, Date_Time, URL, pointsLayer, mapView, testWarning
200204
events: {
201205
onStateChange: onPlayerStateChange,
202206
onReady: (event) => {
203-
event.target.seekTo(player.current.getCurrentTime(), true);
207+
if (player.current) {
208+
event.target.seekTo(player.current.getCurrentTime(), true);
209+
}
204210
}
205211
}
206212
});

0 commit comments

Comments
 (0)