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

Detecting end of mp4 in video component

Community Beginner ,
Jan 18, 2018 Jan 18, 2018

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
3.2K
Translate
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.

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

what's _this?

Translate
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

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

Translate
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

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.

Translate
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

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);

    }

}

Translate
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

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

Translate
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

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.

Translate
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

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);

     }

}

Translate
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

what kind of project?

html5/canvas or actionscript?

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

Translate
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

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.

Translate
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

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

Translate
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

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

Translate
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

Like these:

var videoURL = "video.mp4";

or

var videoURL = "video_folder/video.mp4";

Translate
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

Where do I indicate frame number for "goto"?

Translate
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
  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. }
Translate
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

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

Translate
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

just use the correct path to your video

Translate
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
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);

}

Translate
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

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

Screenshot 2018-01-19 10.00.51.png

Translate
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

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.

Translate
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

Thanks for pointing me in the right direction.

Translate
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

you're welcome.

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

Translate
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

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

Translate
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

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

Translate
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

this is an html5 thread.

Translate
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