@@ -30,9 +30,14 @@ export function SetupVideoEditing(container) {
3030 // debugging, and just might prevent a problem in normal operation.
3131 videoElement . parentElement ?. classList . remove ( "playing" ) ;
3232 videoElement . parentElement ?. classList . remove ( "paused" ) ;
33- videoElement . addEventListener ( "click" , handleVideoClick ) ;
33+ const mouseDetector =
34+ videoElement . ownerDocument . createElement ( "div" ) ;
35+ mouseDetector . classList . add ( "bloom-videoMouseDetector" ) ;
36+ mouseDetector . classList . add ( "bloom-ui" ) ; // don't save as part of document
37+ mouseDetector . addEventListener ( "click" , handleVideoClick ) ;
38+ videoElement . parentElement ?. appendChild ( mouseDetector ) ;
3439 const playButton = wrapVideoIcon (
35- videoElement ,
40+ mouseDetector ,
3641 // Alternatively, we could import the Material UI icon, make this file a TSX, and use
3742 // ReactDom.render to render the icon into the div. But just creating the SVG
3843 // ourselves (as these methods do) seems more natural to me. We would not be using
@@ -43,13 +48,13 @@ export function SetupVideoEditing(container) {
4348 ) ;
4449 playButton . addEventListener ( "click" , handlePlayClick ) ;
4550 const pauseButton = wrapVideoIcon (
46- videoElement ,
51+ mouseDetector ,
4752 getPauseIcon ( "#ffffff" , videoElement ) ,
4853 "bloom-videoPauseIcon" ,
4954 ) ;
5055 pauseButton . addEventListener ( "click" , handlePauseClick ) ;
5156 const replayButton = wrapVideoIcon (
52- videoElement ,
57+ mouseDetector ,
5358 getReplayIcon ( "#ffffff" , videoElement ) ,
5459 "bloom-videoReplayIcon" ,
5560 ) ;
@@ -296,17 +301,17 @@ export function updateVideoInContainer(container: Element, url: string): void {
296301// configure one of the icons we display over videos. We put a div around it and apply
297302// various classes and append it to the parent of the video.
298303function wrapVideoIcon (
299- videoElement : HTMLVideoElement ,
304+ parent : HTMLElement ,
300305 icon : HTMLElement ,
301306 iconClass : string ,
302307) : HTMLElement {
303- const wrapper = videoElement . ownerDocument . createElement ( "div" ) ;
308+ const wrapper = parent . ownerDocument . createElement ( "div" ) ;
304309 wrapper . classList . add ( "bloom-videoControlContainer" ) ;
305310 wrapper . classList . add ( "bloom-ui" ) ; // don't save as part of document
306311 wrapper . appendChild ( icon ) ;
307312 wrapper . classList . add ( iconClass ) ;
308313 icon . classList . add ( "bloom-videoControl" ) ;
309- videoElement . parentElement ? .appendChild ( wrapper ) ;
314+ parent . appendChild ( wrapper ) ;
310315 return icon ;
311316}
312317
0 commit comments