Buzul Posted June 11, 2018 Share Posted June 11, 2018 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();} Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 11, 2018 Share Posted June 11, 2018 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. Buzul 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted June 12, 2018 Share Posted June 12, 2018 @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 Buzul 1 Quote Link to comment Share on other sites More sharing options...
Magilla Posted June 12, 2018 Share Posted June 12, 2018 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. Buzul 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 12, 2018 Share Posted June 12, 2018 Hey, I just created an actionManager. I'm not responsible for any other drama. :) Quote Link to comment Share on other sites More sharing options...
Magilla Posted June 12, 2018 Share Posted June 12, 2018 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. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Buzul Posted June 13, 2018 Author Share Posted June 13, 2018 @Wingnut you are legent.. thank you so much.. I'm new at babylon.. This is my question's answer... Thank you.. @Magilla thanks for the extra information.. Wingnut and Magilla 2 Quote Link to comment Share on other sites More sharing options...
Buzul Posted June 20, 2018 Author Share Posted June 20, 2018 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? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted June 20, 2018 Share Posted June 20, 2018 Is it not simply the array of videos defined during the texture creation ? ["video/vexpovid.mp4", "video/vexpovid.webm"] Quote Link to comment Share on other sites More sharing options...
Buzul Posted June 20, 2018 Author Share Posted June 20, 2018 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.. Quote Link to comment Share on other sites More sharing options...
dbawel Posted June 20, 2018 Share Posted June 20, 2018 @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 Quote Link to comment Share on other sites More sharing options...
Buzul Posted June 21, 2018 Author Share Posted June 21, 2018 @dbawel thanks for your comment.. actually i'm c# developer and i can work with arrays but i'm new in babylon. I'll try your way and i'll let you know.. Thank you.. dbawel 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.