Copy link to clipboard
Copied
Hi all-
I have a video component named "mainVideo" and a mute button called "mute_mc" on the stage, I can do something like this without any problem:
this.mute_mc.addEventListener("click", fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler()
{
$("#mainVideo")[0].mute();
}
but now I want to mute the video without click event, I tried something like this:
$("#mainVideo")[0].mute();
and the console threw me an error message said: Uncaught TypeError: Cannot read property 'mute' of undefined(…)
Does anyone know what should I do to reference the video component in this case?
Thanks,
Chih-Wei
This error occurs because the video component might not have completely initialized by the time yourmute code is hit via frame scripts.
We're enabling a quick and easy way of setting the mute property for videos and it should be available with the upcoming update of Animate very shortly.
Copy link to clipboard
Copied
I don't really know jquery at all. If you just do this:
fl_MouseClickHandler();
does that work? Failing that, maybe you have to make it seem like a user action. trigger might be the right thing to use:
Copy link to clipboard
Copied
i've tried but no good luck
Copy link to clipboard
Copied
Are you able to put something online. The least number of files to be able to show the problem?
Copy link to clipboard
Copied
Hi Colin, here is the file, thanks for helping!
https://dl.dropboxusercontent.com/u/30282830/video_component.zip
Copy link to clipboard
Copied
play() seems to be the opposite of pause(). This code will let you pause and paly:
//this work
this.mute_mc.addEventListener("click", fl_MouseClickHandler.bind(this));
var ispaused = false;
function fl_MouseClickHandler() {
ispaused = !ispaused;
if (!ispaused) {
$("#myVideo")[0].play();
} else {
$("#myVideo")[0].pause();
}
//<video id="myVideo"></video>
console.log($("#myVideo")[0]);
}
You didn't include examples of the mute feature, but maybe you meant play/pause, and not sound/no sound.
Copy link to clipboard
Copied
Hi Colin, thanks for your reply. I guess I didn't express my question well. I know how to make video play/pause or sound on/off, let's say if I want to add an event listener when video is completed (not triggered by click event):
$("myVideo")[0].addEventListener('ended', endEvent)
function endEvent()
{
//do something
}
then the console shows the error message says $("myVideo")[0] is undefined.
It seems $("myVideo")[0] only works when I put it in the function and trigger it by using the click event, if I took $("myVideo")[0] outside of the function or simply call the function then it won't work.
Thanks.
Copy link to clipboard
Copied
This error occurs because the video component might not have completely initialized by the time yourmute code is hit via frame scripts.
We're enabling a quick and easy way of setting the mute property for videos and it should be available with the upcoming update of Animate very shortly.
Copy link to clipboard
Copied
I don't have an answer for your question, I just want to express my horror (well, mild disapproval) at the use of jQuery where a simple document.getElementById() would have sufficed.
Copy link to clipboard
Copied
They seem to be using jquery for other things too, that might have been harder to achieve.