• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Animate CC2017 video component instance name

Explorer ,
Dec 07, 2016 Dec 07, 2016

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

Views

667

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Dec 09, 2016 Dec 09, 2016

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.

Votes

Translate

Translate
LEGEND ,
Dec 07, 2016 Dec 07, 2016

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:

http://api.jquery.com/trigger/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

i've tried but no good luck 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

Are you able to put something online. The least number of files to be able to show the problem?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

Hi Colin, here is the file, thanks for helping!

https://dl.dropboxusercontent.com/u/30282830/video_component.zip

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2016 Dec 08, 2016

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 08, 2016 Dec 08, 2016

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2016 Dec 08, 2016

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

They seem to be using jquery for other things too, that might have been harder to achieve.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines