Play() pause() and paused for a VideoDome

What is the correct syntax to pause a video on a 360 3D VideoDome in immersive mode? I have a 3D video on a VideoDome that works. I want to pause, and restart it, and check its status. I can’t seem to get the syntax exactly right.

I have

                  var Dome = new BABYLON.VideoDome
                                (
                                    "videoDomeZ",
                                    [vid],
                                    {
                                        resolution: 32,
                                        clickToPlay: true,
                                        mesh: planeZ,
                                    },
                                    scene
                                );

                            Dome.videoMode = BABYLON.VideoDome.MODE_SIDEBYSIDE;

That works, and I seem to be able to check the status with Dome.videoTexture.video.paused.

But I can not seem to pause it with Dome.videoTexture.video.pause().

Do I need to extract the videoTexture (or VideoTexture?) from the Dome. I’m not sure what the syntax is. I can guess that it might be something like…

var texture = Dome.getVideoTexture() (or something like that)
texture.video.pause();

Will the correct syntax pause both the video and the audio or must they be paused independently?

Thanks!

It should pause video and sound and your syntax seems correct knowing video is the underlying videoElement so not controlled by Babylon here.

Could you repro in the playground ? so we ll have a look.

After a lot of research, it appears the problem may be that although the video can be paused in POINTERDOWN while the trigger is pulled, after the trigger is released it begins to play again whether or not there are commands in POINTERUP.

When a POINTERDOWN is triggered, the video in the Dome pauses WHILE the trigger is held down. The Dome.videoTexture.video.paused boolean correctly says TRUE.

However, when the trigger is released, even if there is a Dome.videoTexture.video.pause() in TRIGGERUP, the video starts playing again; the Dome.videoTexture.video.paused boolean still correctly says TRUE.

It does not matter whether or not there is a mesh – so this problem exists in XR (at least) for both 3D framed SBS and 2D MONOSCOPIC VideoDome videos.

https://www.babylonjs-playground.com/#J1D68N

This shows the problem in the Playground whether viewed on a computer or viewed in 3D with a QUEST. The issue must be solved in all the ways it can be viewed.

Thx.

As you want to control the life cycle of the video you should place clickToPlay: false, in the options:

https://www.babylonjs-playground.com/#J1D68N#3

1 Like

Thanks!

clickToPlay seems to mean more-or-less the opposite of what I thought it meant. (But I’ve never found a definition.) What exactly is the meaning of clickToPlay? What does it do when true? when false?

1 Like

true means the video will play on click :slight_smile: and false means you have to handle it yourself which is what you want.

1 Like

Since changing clickToPlay to false seems to work (thanks, Sebavan!), it is not of critical importance, but I do not understand why clickToPlay = true should “disable” POINTER UP from allowing a pause.

There are some suggestions I found from long ago
(for example: javascript - How can I add click-to-play to my HTML5 videos without interfering with native controls? - Stack Overflow )
that there have been problems with similar settings (like onclick) on the html video tag and that it is browser dependent.

How did you know the solution? From experience? Or is there some relevant documentation or example? I keep looking for helpful documentation and examples.

1 Like

I looked in the code as it is always for me the source of truth regarding what the app does :slight_smile:

ClickToPlay is simply calling play on each pointer up events which would then play no matter what you are also doing before

1 Like

This looks like a bad logical or strategic decision in the design or in the naming. There is no deliberate click for the purpose of playing, here (which is how it seems most simple to understand “clickToPlay”. This shows part of what I surmised: As you say, it seems to say that no matter what you tell Dome on POINTER DOWN (even unrelated to play/pause) the video should start to play when the POINTER goes UP.

But that still leaves open the question of why Dome.videoTexture.video.paused shows true even after this plays the video.

I’m guessing you found this in github, since my tries at finding this with Google searches didn’t work, and I’m not skilled at finding code within github. How did you locate this fragment? There is a ton of code for Babylon and I find it hard to navigate thru it.

1 Like

You can clone the repo locally and browse/search within VSCode.

1 Like

:100: I wish I had started searching for and reading Babylon code in VSCode much sooner, it’s so much nicer than using GitHub for that, which I did for a long time LOL… :slightly_smiling_face:

1 Like

Or on the github project page GitHub - BabylonJS/Babylon.js: Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework. just press the . key to open an online version :slight_smile:

2 Likes

That sounds awesome too, but I couldn’t find the . key. Is it setup with code space or something? :eyes:

just press . on your keyboard :slight_smile: it will open GitHub web editor

1 Like

Excellent, once I followed the link, logged in and setup VSCode, then pressing the . key from the Babylon repo worked like a charm! :slightly_smiling_face: :beers:

P.S., LOL I can’t believe I’ve been browsing GitHub source online without online VSCode all this time, thanks for the tip! :beers:

1 Like