Sign in to follow this  
Buzul

Video pause problem (Help)

Recommended Posts

Hi everyone i'm new guy in here..

I have a problem.. I'm playing a video with videoTexture but i want to make when i clicked to videoTexture to pause video..

 

I followed this topic: http://www.babylonjs-playground.com/#CHQ4T#5

everyting well but when I click anywhere  on the scene video stoping

 

 

Here is my code

var videomat = new BABYLON.StandardMaterial("Videomat", scene);

            var videoTexture = new BABYLON.VideoTexture("video", ["video/vexpovid.mp4", "video/vexpovid.webm"], scene, true,true);

            var videobox = BABYLON.MeshBuilder.CreateBox('videobox', optionsVideo, scene);
            videobox.position.x = -120;
            videobox.position.y = 300;
            videobox.position.z = 163;
            videobox.rotation.y =3.15;
            videobox.material = videomat;

            videomat.diffuseTexture = videoTexture;
            videobox.material = videomat;


            scene.onPointerDown = function () {
                //videoTexture.video.play();

                if (videoTexture.video.paused){
                    videoTexture.video.play();
                } else { videoTexture.video.pause();}

 

Share this post


Link to post
Share on other sites

Hiya B!  Welcome to the forum.

http://www.babylonjs-playground.com/#CHQ4T#73

There, you can see that I changed from scene.onPointerDown... to using a BabylonJS ActionManager... a super-handy tool.

Now, user must click on the video plane... to make pause/un-pause work.  I hope this helps.

Share this post


Link to post
Share on other sites

@Buzul

@Wingnut is correct. Depending on the device, video.play and video.pause react differently. As an example, if you want a video to begin playing on Android when the scene is loaded without any user interaction, this works fine. However, no video functions will initiate without user interaction such as a click event. This varies from OS to browser to device over the past 4 years, and it's taken me quite a bit of time to discover all of the differences when utilizing media.

DB

Share this post


Link to post
Share on other sites
12 hours ago, Buzul said:

scene.onPointerDown = function () { //videoTexture.video.play(); if (videoTexture.video.paused){ videoTexture.video.play(); } else { videoTexture.video.pause();}

This is where your bug is - it's a concept/algorithm bug. The problem is that you are running the pause/play code for all onPointerDown events for the WHOLE SCENE. Therefore, it doesn't matter where you click on the screen, it controls the video. Exactly what your code asks for, although not what you intended.

What you need to do is check for onPointerDown on the surface that you want to use to control the video, rather than the entire scene. And that's what @Wingnut has demonstrated in the playground link.

Share this post


Link to post
Share on other sites
42 minutes ago, Wingnut said:

Hey, I just created an actionManager.  I'm not responsible for any other drama.  :)

Indeed. I'm just trying to explain why it went wrong originally, and how you went about solving the issue from a conceptual standpoint.

Share this post


Link to post
Share on other sites

Hi again everybody...I'm writing here because my new problem about this topic..

I solved my old problem as above.. I need your suggestions for create a play list for videos.. How can i do that with continue from above simple?

Share this post


Link to post
Share on other sites
2 hours ago, Sebavan said:

Is it not simply the array of videos defined during the texture creation ?  ["video/vexpovid.mp4", "video/vexpovid.webm"]

 

 

I mean multiple video file.. when i want to use multiple video file how can i done it with above technic..

Share this post


Link to post
Share on other sites

@Buzul

An array can hold any # of data/objects/videos whatever you want. So if your array is named videos[ ], then the first video you push to the array will be videos[0], the second video you push will be videos[1] and on and on. If you're not familiar with arrays, then you MUST learn. It's very simple.

DB

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.