Sign in to follow this  
dbawel

Syntax for playing and pausing video textures

Recommended Posts

Hello,

 

Sorry I've been out for a month - I doubt anyone missed me.  :(  I had to travel to Thailand (my Wife is Thai) for personal family issues which will take me back to Thailand on the 24th.  So I had to put my multiuser real time drawing app on hold.  But now I want to complete the first version in the next week, and am really stuck on something today.

 

I have buttons that send the correct values to my conditional statements, but I don't know what the operation or proper syntax is to play and pause a video texture within my conditions.  I must be missing something as this doesn't seem that difficult.

 

I can certainly get these statements to cause a play or pause operation:

videoTexture.video.play();

videoTexture.video.pause();

but only once in my scene and not in a conditional statement.

 

 

I assume I must be missing further declaration - potentially for the object the video is playing attached as a diffuse video texture. Perhaps something similar to:

scene.getMeshById("mymesh").visibility = 0;

to set visibility and other attibutes for an object.

 

I often use for a simple switch:

plane.actionManager = new BABYLON.ActionManager(scene);
plane.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function () {
videoTexture.video.pause();
}));

but certainly remark this out as in this case it might cause a conflict with my conditions.  So how might I pause and play a video texture in a conditional statement?

 

As always, your help is greatly appriciated.

 

Cheers,

 

DB

 

 

 

 

Share this post


Link to post
Share on other sites

Hi DB,

 

I am not sure I am following.

videoTexture.video is an HTML element which you can control any way you want. using a simple code like this:

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

you can toggle between the two states very easily. But I guess this is not what you meant.

What conflict does it cause?

 

Oh, and of course we missed you :)

Share this post


Link to post
Share on other sites

Hey RaananW,

 

Thank you for the welcome back. :)  I have one week then back to Thailand until Dec.  Anyway, those are the functions I've been using, but to attach them to the interface, I cannot get the video to be played or paused using a condition with booleen values.  One example I have is this:

 

if (videoplay = 1) {
videoTexture.video.play();
} else {
videoTexture.video.pause();
}
 
if (videopause = 1) {
videoTexture.video.pause();
} else {
videoTexture.video.play();
}

I also have more complex examples, but I was reaching for anyting at that point.  I need to use the interface buttons as I'm drawing on 3D objects with the mouse events, and there will be more video playback controls required soon. I've tried everything I know to date, so I must be missing something.  Any ideas are always appriciated.

 

Share this post


Link to post
Share on other sites

why don't you use the video player's state? videoTexture.video.paused ? HTML5 video tag has a lot of properties and tags that can be used exactly for those cases.

What is videoplay? where is it defined? (and of course, as JC said, it shoudl be == or === :-) )

Share this post


Link to post
Share on other sites

Hello Gentlemen,

 

Thank you for the input, I took a shortcut on my post and generally use == but have also used ===, and not simply = , my bad.  Here's the actual code currently in my script:

 

if (videoplay === 1) {
videoTexture.video.play;
} else {
videoTexture.video.pause();
}
 
if (videopause === 1) {
videoTexture.video.pause;
} else {
videoTexture.video.play();
}

Where videopause is a global variable whose value is assigned to buttons on the interface.  I've certainly console logged the values when I press the buttons, and as I'm only attempting to play and pause video at this time, the buttons return a simple booleen of 0 or 1 - which are registered correctly.  I'm completely at a loss. The only other info that might assist are the file formats I'm calling, which should have no impact - unless I have something wrong in calling the videoTexture:

 

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

 

 

Pehaps the switches in the operation are incorrect - not from the documentation at least.  Perhaps I need to operate on the "plane" mesh the video is assigned as an emmisive texture?

 

As always, thanks.

Share this post


Link to post
Share on other sites

Well, you can ignore my post above, as I just made a simple test to translate an object using the same condition, and it failed.  This tells me that I have a larger conflict in my scene.  I'm controlling everything else thus far by calling functions - which is working to change attributes.  So I'll create a function to test a simple operation to see if that works.  Then I'll worry about whether my GUI is conflicting with the scene, since I'm using extensions - which are broadly untested, and report back.

Share this post


Link to post
Share on other sites

Hi Dad72,

 

Thank you for the scene.  I haven't tracked down the problem yet, but I now know it's some other conflict in my scene - most likely in the use of the elements and extensions I have set up.  I have to strip my app down to the most basic of elements, and test further.  When I find the problem, I'll post the code - or what the conflict was as the scripts are quite large, and the conflict could be anything.  But it hasn't been the video playback, as I suspected since I've tested every possibility as well, and this is something much worse, which the debugger won't register.

 

As always, Thanks.

Share this post


Link to post
Share on other sites

Thank you to everyone who has posted help on this.  I finally discovered what the issue is.  For my interface, in using the bGui extension, and even though I placed every element and attribute inside of the render loop for the scene, in looking far more closely at how the extension is called, all elements must exist inside of the bGui function, but not all other functions - such as those functions controlling more than one canvas or elments such as DynamicTextures on objects (this is a very simple explaination, as it's not quite that simple.)  However, I do really like the bGui extension, and will also try the other GUI extensions for BJS soon, as I feel these are a huge asset to working more efficiently.  Perhaps Dad72's CasterGUI next?

 

So now I can move forward quickly, although I need to reformat my entire app as I can simplify the scripting quite a bit - perhaps a day's work (I hope).  I believe I can finish the app now before I have to return to Thailand next week.  The brand new real time multiuser WebsocketIO and node.js server we built has been working flawlessly for months now, so wish me luck.

 

Cheers for now,

 

DB

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.