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

Detecting end of mp4 in video component

Community Beginner ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

I have an HTML Canvas file setup that plays a simply animation at the beginning then a keyframe is set to stop the timeline and I have an .mp4 play in a video component object. This works well until I add code to detect when the movie has reached its end so I can move ahead to the next frame in the timeline.

How is that done? I've tried a few things I've found on the web but they are all from around 2011.

The follow just gives me a blank white screen:

_this.stream.addEventListener(NetStatusEvent.NET_STATUS, statusChanged);

function statusChanged(stats:NetStatusEvent) {

    if (stats.info.code == 'NetStream.Play.Stop') {

         _this.gotoAndStop(85);

    }

}

TOPICS
ActionScript

Views

2.1K

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 , Jan 19, 2018 Jan 19, 2018

your code is completely wrong, then.  you're using the wrong scripting language.

you must remove every line of code.  then you must use javascript and can use createjs, CreateJS | A suite of JavaScript libraries and tools designed for working with HTML5

you can try the code in message 9 using a local path to your mp4 or don't even assign the src propertly if you're using the component parameters panel to assign the source.

Votes

Translate

Translate
Community Expert ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

what's _this?

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 ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

I think "_this" denotes the current scene you're on, but even if I remove it I still just get a blank page.

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 Expert ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

it doesn't denote that unless you define it.  you probably want to use "this", not "_this".

also, you're using actionscript and you indicated you have a html5/canvas project:  that won't work.  html5/canvas uses javascript/createjs.

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 ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

Changing the code to the follow doesn't work either:

var _this = this;

_this.stream.addEventListener(NetStatusEvent.NET_STATUS, statusChanged);

function statusChanged(stats:NetStatusEvent) {

    if (stats.info.code == 'NetStream.Play.Stop') {

         _this.gotoAndStop(85);

    }

}

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
Advisor ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

it would be easier to solve your problem if you provide the full code

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 ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

That is all I've attempted. There is no other code. I simply have an mp4 embedded using the video component and have an idea what I need to include as far as code to detect when the mp4 has finished playing.

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
Advisor ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

If you mean "video component" = "video object" from video class and if your code

is on the first frame of the timeline

so do just

myNetStreamObject.addEventListener(NetStatusEvent.NET_STATUS,onNetStreamStatus);

function onNetStreamStatus(event:NetStatusEvent) :void{

     if (event.info.code == "NetStream.Play.Stop"){

          gotoAndStop(85);

     }

}

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 Expert ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

what kind of project?

html5/canvas or actionscript?

if you're not sure, attach a screenshot of your publish settings (file>publish settings).

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 Expert ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

Isn't NetStatusEvent.NET_STATUS AS3?

Anyway... If your video is not in a loop, try this:

var videoURL = "https://images-tv.adobe.com/avp/vr/15a99ccf-0e7c-4601-b270-87dd82624086/5078a43c-81f9-4a93-836c-8152...";

this.video.on("added", function() {

    $("#video")[0].src = videoURL;

    $("#video")[0].addEventListener('ended',myHandler,false);

}, this, true);

function myHandler(e)

{

      console.log("Video finished playing.");

}

"video" is the instance name of your video component.

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 Expert ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

yes, that code is as3 and will fail in an html5 project so it's not clear what she's doing.

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 ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

What if the mp4 is a local file and not a URL?

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 Expert ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

Like these:

var videoURL = "video.mp4";

or

var videoURL = "video_folder/video.mp4";

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
Participant ,
Jan 29, 2018 Jan 29, 2018

Copy link to clipboard

Copied

Where do I indicate frame number for "goto"?

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 Expert ,
Jan 29, 2018 Jan 29, 2018

Copy link to clipboard

Copied

  1. var this_var=this;
  2. var videoURL = "https://images-tv.adobe.com/avp/vr/15a99ccf-0e7c-4601-b270-87dd82624086/5078a43c-81f9-4a93-836c-8152..."
  3.  
  4. this.video.on("added", function() { 
  5.     $("#video")[0].src = videoURL; 
  6.     $("#video")[0].addEventListener('ended',myHandler,false); 
  7. }, this, true); 
  8.  
  9. function myHandler(e) 
  10.      this_var.gotoAndStop('wherever');
  11. }

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
Participant ,
Jan 29, 2018 Jan 29, 2018

Copy link to clipboard

Copied

If the video is local, do I need the top 3 lines re: URL?  And just rename "video" to my video instance name?

Appreciate this help so much.  rg

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 Expert ,
Jan 29, 2018 Jan 29, 2018

Copy link to clipboard

Copied

just use the correct path to your video

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
Participant ,
Apr 12, 2018 Apr 12, 2018

Copy link to clipboard

Copied

LATEST

I tried the code below, and then it would not play at all.

var this_var=this;

var videoURL = videos/movie1.mp4

this.video.on("added", function()

{

    $("#video")[0].src = videoURL;

    $("#video")[0].addEventListener('ended',myHandler,false);

}, this, true);

function myHandler(e)

{

this_var.gotoAndPlay(22);

}

//manual return to home button action below//

this.home_btn.addEventListener("click", fl_ClickToGoToAndPlayFromFrame_3.bind(this));

function fl_ClickToGoToAndPlayFromFrame_3()

{

this.gotoAndPlay(22);

}

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 ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

It an HTML5/Canvas. And just to clarify what I'm doing, here's a screenshot.

Screenshot 2018-01-19 10.00.51.png

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 Expert ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

your code is completely wrong, then.  you're using the wrong scripting language.

you must remove every line of code.  then you must use javascript and can use createjs, CreateJS | A suite of JavaScript libraries and tools designed for working with HTML5

you can try the code in message 9 using a local path to your mp4 or don't even assign the src propertly if you're using the component parameters panel to assign the source.

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 ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

Thanks for pointing me in the right direction.

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 Expert ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

you're welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

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
Participant ,
Jan 29, 2018 Jan 29, 2018

Copy link to clipboard

Copied

Couldn't quite follow explanation for creating code snippet for creating an event when MP4 video ends.

I simply want to return to a menu frame on timeline when each of several movies ends.  Each has a separate instance.

Appreciate the hint.

rg

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
Advisor ,
Jan 29, 2018 Jan 29, 2018

Copy link to clipboard

Copied

use event "NetStream.play.stop" from Netstream NetStatus event

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 Expert ,
Jan 29, 2018 Jan 29, 2018

Copy link to clipboard

Copied

this is an html5 thread.

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