@@ -31,9 +31,14 @@ export function SetupVideoEditing(container) {
3131 // debugging, and just might prevent a problem in normal operation.
3232 videoElement . parentElement ?. classList . remove ( "playing" ) ;
3333 videoElement . parentElement ?. classList . remove ( "paused" ) ;
34- videoElement . addEventListener ( "click" , handleVideoClick ) ;
34+ const mouseDetector =
35+ videoElement . ownerDocument . createElement ( "div" ) ;
36+ mouseDetector . classList . add ( "bloom-videoMouseDetector" ) ;
37+ mouseDetector . classList . add ( "bloom-ui" ) ; // don't save as part of document
38+ mouseDetector . addEventListener ( "click" , handleVideoClick ) ;
39+ videoElement . parentElement ?. appendChild ( mouseDetector ) ;
3540 const playButton = wrapVideoIcon (
36- videoElement ,
41+ mouseDetector ,
3742 // Alternatively, we could import the Material UI icon, make this file a TSX, and use
3843 // ReactDom.render to render the icon into the div. But just creating the SVG
3944 // ourselves (as these methods do) seems more natural to me. We would not be using
@@ -44,13 +49,13 @@ export function SetupVideoEditing(container) {
4449 ) ;
4550 playButton . addEventListener ( "click" , handlePlayClick ) ;
4651 const pauseButton = wrapVideoIcon (
47- videoElement ,
52+ mouseDetector ,
4853 getPauseIcon ( "#ffffff" , videoElement ) ,
4954 "bloom-videoPauseIcon" ,
5055 ) ;
5156 pauseButton . addEventListener ( "click" , handlePauseClick ) ;
5257 const replayButton = wrapVideoIcon (
53- videoElement ,
58+ mouseDetector ,
5459 getReplayIcon ( "#ffffff" , videoElement ) ,
5560 "bloom-videoReplayIcon" ,
5661 ) ;
@@ -302,17 +307,17 @@ export function updateVideoInContainer(container: Element, url: string): void {
302307// configure one of the icons we display over videos. We put a div around it and apply
303308// various classes and append it to the parent of the video.
304309function wrapVideoIcon (
305- videoElement : HTMLVideoElement ,
310+ parent : HTMLElement ,
306311 icon : HTMLElement ,
307312 iconClass : string ,
308313) : HTMLElement {
309- const wrapper = videoElement . ownerDocument . createElement ( "div" ) ;
314+ const wrapper = parent . ownerDocument . createElement ( "div" ) ;
310315 wrapper . classList . add ( "bloom-videoControlContainer" ) ;
311316 wrapper . classList . add ( "bloom-ui" ) ; // don't save as part of document
312317 wrapper . appendChild ( icon ) ;
313318 wrapper . classList . add ( iconClass ) ;
314319 icon . classList . add ( "bloom-videoControl" ) ;
315- videoElement . parentElement ? .appendChild ( wrapper ) ;
320+ parent . appendChild ( wrapper ) ;
316321 return icon ;
317322}
318323
@@ -336,6 +341,7 @@ export function handlePlayClick(ev: MouseEvent, forcePlay?: boolean) {
336341 // becuse the click might be a drag on the canvas element. We'll let CanvasElementManager
337342 // decide and call playVideo if appropriate. That is, if we're not in Play mode,
338343 // where dragging is not applicable, or being called FROM the CanvasElementManager.
344+ // TODO The above comment is out of date; there
339345 if (
340346 ! forcePlay &&
341347 video . closest ( kCanvasElementSelector ) &&
@@ -391,12 +397,14 @@ function handlePauseClick(ev: MouseEvent) {
391397// be a natural bit of code to put in dragActivityRuntime.ts, except we don't need
392398// it there, because BloomPlayer has this behavior for all videos, not just in Games.)
393399const handleVideoClick = ( ev : MouseEvent ) => {
394- const video = ev . currentTarget as HTMLVideoElement ;
400+ const video = ( ev . currentTarget as HTMLElement )
401+ ?. closest ( ".bloom-videoContainer" )
402+ ?. getElementsByTagName ( "video" ) [ 0 ] ;
395403
396404 // If we're not in Play mode, we don't need these behaviors.
397405 // At least I don't think so. Outside Play mode, clicking on canvas elements is mainly about moving
398406 // them, but we have a visible Play button in case you want to play one. In BP (and Play mode), you
399- // can't move them (unless one day we make them something you can drag to a target) , so it
407+ // can't move them if they aren't draggable , so it
400408 // makes sense that a click anywhere on the video would play it; there's nothing else useful
401409 // to do in response.
402410 if ( ! video . closest ( ".drag-activity-play" ) ) {
0 commit comments