Jump to content

Video pause problem (Help)


Buzul
 Share

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();}

 

Link to comment
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

Link to comment
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.

Link to comment
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.

Link to comment
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?

Link to comment
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..

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...