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

HTML5 Canvas action at the end of a video

Community Beginner ,
Mar 02, 2022 Mar 02, 2022

Copy link to clipboard

Copied

Hello everybody,

 

I'm using Animate HTML5 Canvas project with a component Video into a frame on the timeline (full screen).

Now I need to do a "GotoAndStop" at a certain frame once the video is ended.

How can I do that ?

Best regards

Views

92

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

Community Expert , Mar 02, 2022 Mar 02, 2022

Hi.

 

This should work (the loop property of the Video component must be set to false) :

 

 

var root = this;
var videoID = "yourVideoID"; // the id is set in the Properties panel when the video component is selected
var video;

function drawEndHandler()
{
	video = document.getElementById(videoID);
	video.addEventListener("ended", endedHandler);
}

function endedHandler()
{
	video.removeEventListener("ended", endedHandler);
	root.gotoAndStop(1);
}

root.stop();
stage.on("drawend", drawEndHandler
...

Votes

Translate

Translate
Community Expert ,
Mar 02, 2022 Mar 02, 2022

Copy link to clipboard

Copied

Hi.

 

This should work (the loop property of the Video component must be set to false) :

 

 

var root = this;
var videoID = "yourVideoID"; // the id is set in the Properties panel when the video component is selected
var video;

function drawEndHandler()
{
	video = document.getElementById(videoID);
	video.addEventListener("ended", endedHandler);
}

function endedHandler()
{
	video.removeEventListener("ended", endedHandler);
	root.gotoAndStop(1);
}

root.stop();
stage.on("drawend", drawEndHandler, null, true);

 

 

 

I hope it helps.

 

Regards,

JC

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
Community Beginner ,
Mar 02, 2022 Mar 02, 2022

Copy link to clipboard

Copied

LATEST

Just perfect, working so fine.

It's magical 🙂

Thank you, all best

Philippe

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