Skip to main content
Participant
April 22, 2017
Answered

how to access timeline when html5 video is played in adobe animate cc

  • April 22, 2017
  • 2 replies
  • 1299 views

hi every body..

I've searched long time...

I 'm working on html 5 canvas project using adobe animate cc. I 've mp4 video on the timeline and I have some content on the timeline.

The question is How can I make the timeline start playing when I click  on the play button of the video ??

I've used the following, but it did not work...

var pos = 0;

// Assign an ontimeupdate event to the video element, and execute a function if the current playback position has changed

vid.ontimeupdate = function() {myFunction()};

function myFunction() {

  pos = Math.round(vid.currentTime*24);

  // where 24 is the current frame rate

  inputTxt.value = pos;

  this.stop(pos+1);

}

    This topic has been closed for replies.
    Correct answer ClayUUID

    I've done that but still not work.. the play head dos not move ..

    When I add

      alert(this);

    inside function myFunction() .. I get [Object window ] message..

    The question still How Can I refer to the timeline to play the play head??


    Event handlers default to executing in the global window context. Yes, this was a very poorly thought out design decision, but now we're stuck with it.

    To force a function to execute in a specific context, you have to use .bind() on it.

    Function.prototype.bind() - JavaScript | MDN

    2 replies

    Participant
    April 23, 2017

    A little correctness:

    this.play(pos+1); instead of  this.stop(pos+1);

    Legend
    April 23, 2017

    Neither are correct. Only gotoAndStop() and gotoAndPlay() take frame numbers.

    Participant
    April 24, 2017

    I've done that but still not work.. the play head dos not move ..

    When I add

      alert(this);

    inside function myFunction() .. I get [Object window ] message..

    The question still How Can I refer to the timeline to play the play head??

    Legend
    April 22, 2017

    Sticking an alert(this); in your event handler would be enlightening.