Copy link to clipboard
Copied
I would like to know if it is possible using AS3 to loop [ seamlessly or even slightly un-seamlessly! ] an externally loaded video - encoded as h.264
I have searched many leads trying to find out if this is currently viable. It doesn't seem as easy as I imagined it would be.
I have member of my team that knows some AS2 - and has very little knowledge of AS3. He wrote scripts for looping functionality in AS2 - however as we need to upgrade to Adobe Animate CC to use 4k video for a large touchscreen application - so we are trying to find out if looping video, loaded externally, can be scripted for in AS3.
It actually seems pretty crazy to me that such a feature is so hard to achieve. I would have thought that in today's media saturated world, this would be a basic and simple requirement.
If anyone can point me in the right direction I would be grateful. I need to determine whether to upgrade to Animate or to stay with CS5.5, and HD 1080p video.
Copy link to clipboard
Copied
yes, you can loop (but not seamlessly).
how are you playing your video? ie, are you using a flvplayback component, video component, as3 netstream?
Copy link to clipboard
Copied
we will do it any way that you suggest is best. In other words we are not doing it yet....
If you mean in AS2 however, we were doing it by a flvplayback component.
thanks for the reply BTW
Copy link to clipboard
Copied
use the flvplayback component with as3. it's the easiest way to play video.
if your component has instance name, flv_pb you can use the following to loop:
flv_pb.addEventListener(fl.video.VideoEvent.COMPLETE,completeF);
function completeF(e:fl.video.VideoEvent):void{
flv_pb.play(path/filename);
}
Copy link to clipboard
Copied
wow - that looks and sound pretty straightforward - and it works with current version of animate?
Copy link to clipboard
Copied
yes.
Copy link to clipboard
Copied
I can report that this code is not working for me in Animate CC 2017. If I simply import a h264 compressed .mov using the "Load external video" with the "none" skin, it shows up on frame 1. I name the instance "flv_pb" and the movie file (3SceCountBlue.mov) is in the same directory as the saved .fla project. The code on the first frame is:
stop();
flv_pb.addEventListener(fl.video.VideoEvent.COMPLETE,completeF);
function completeF(e:fl.video.VideoEvent):void{
flv_pb.play("3SceCountBlue.mov");
}
When I try and test it I get an error:
1046: Type was not found or was not a compile-time constant: VideoEvent
Copy link to clipboard
Copied
are you using an as3 project or html5/canvas project?
if as3, did you import the videoevent?
import fl.video.VideoEvent;
Copy link to clipboard
Copied
It is AS3 and I sure did.
I meant to go back and post that I had added the VideoEvent AS commands. The code now looks like this:
import fl.video.VideoEvent;
stop();
flv_pb.addEventListener(fl.video.VideoEvent.COMPLETE, completeF);
function completeF(e: fl.video.VideoEvent): void {
flv_pb.play("3SceCountBlue.mov");
}
Interestingly, when I went back it did not throw an error. However, it also did not loop. The video payed for the 3 seconds and then froze on the last frame.
I also uploaded a zip of the project (and 3 second video) to:
Copy link to clipboard
Copied
add a stop() on the first frame where you have your flvplayback component and that looping code.
add code to play the video in your flvplayback component.
test. any problem?
Copy link to clipboard
Copied
Thanks for trying to help kglad. I do have a stop command on the first frame and it doesn't seem to make a difference. I tried it with and without. Currently the video component is directly on stage and give the flv_pb instance name. When you say:
add code to play the video in your flvplayback component.
do you mean I should nest the video playback instance inside a movie clip and add it there? I don't see a way to insert this code into the flvplayback component itself.
I'm starting to wonder if there is a bug with video looping in this version of Animate CC. I included my link to the file two posts above if you are curious to see if there is a bug in Animate or if it is "pilot error."
Thanks again!
Jerry
Copy link to clipboard
Copied
no.
removed the source for the flvplayback component from the properties panel and use:
import fl.video.VideoEvent;
stop();
flv_pb.addEventListener(fl.video.VideoEvent.COMPLETE, completeF);
flv_pb.play("3SceCountBlue.mov");
function completeF(e: fl.video.VideoEvent): void {
flv_pb.play("3SceCountBlue.mov");
}
Copy link to clipboard
Copied
(logged in under my other screen name to update.)
I tried nesting the FLV component in a movieclip and it STILL doesn't loop. (I did this before I saw your post).
I really thought you were on to something by specifically addressing the video and telling it to play. I removed the video ref and changed the code. But sadly, I get the same result. The video plays once and freezes on the last frame.
Copy link to clipboard
Copied
I also uploaded an update of the looping file demo in case you don't believe I made these changes. Here is a link:
Copy link to clipboard
Copied
try:
function completeF(e: fl.video.VideoEvent): void {
flv_pb.seek(0)
flv_pb.play();
}
Copy link to clipboard
Copied
I have been trying for a while to make it work, including already trying to use seek() to solve the problem. The closest I've got so far is to have two copies of the video and this script:
import fl.video.VideoEvent;
stop();
var n: int = 1;
flv_pb.addEventListener(fl.video.VideoEvent.COMPLETE, completeF);
var f:String = "3SceCountBlue" + n + ".mov"
flv_pb.play(f);
function completeF(e: fl.video.VideoEvent): void {
n = 3 - n;
f = "3SceCountBlue" + n + ".mov"
flv_pb.play(f);
}
There seems to be a general problem with telling FLVPlayback to play the same video again.
Copy link to clipboard
Copied
adobe must have changed something for the first snippet to fail. but the seek/play works for me with cc 2017.
Copy link to clipboard
Copied
Hey guys... thanks for confirming that I am not completely insane. So I have learned one thing. The file cannot be an H264 ".mov" to loop. I re-saved it as an h262 .mp4 file and it now at least loops. I thought Animator CC supported Quicktime. I guess not.
Now the problem is that when the file loops back, it actually disappears for a full second, leaving a black frame. I've looked at various methods of trying to get a near-seamless loop in Animator CC and the closest I have seen is the idea of using two instances of the video and switching between them. I assume that is what Colin's script aimed to do, however it doesn't work for me (with mov OR MP4).
I can start a new thread for this issue if you think it is appropriate.
SIDEBAR:
It's unfortunate that Adobe is discontinuing Adobe Director. Looping a video was super-easy, you click a radio button. It was the program we used for decades to produce mini-apps for on-set playback in TV and film. I have been tasked with trying to find a replacement, and although Animate CC seemed to be the most likely candidate, I don't think it is going to work.
Copy link to clipboard
Copied
In my one I was reusing the same FLVPlayback component, and it does seem to take a while to connect to its video. With two components you could connect the next one to its video during the playing of the current one, and hopefully it would be ready to play instantly when you need it.
It's good that FLVPlayback can handle any file extension and find the H.264 in the file, but it doesn't take advantage of QuickTime's abilities in the way that Director does. I guess that saving it as MP4 made the file be simpler to handle.
Copy link to clipboard
Copied
Dittio!
"It's unfortunate that Adobe is discontinuing Adobe Director. Looping a video was super-easy, you click a radio button. It was the program we used for decades to produce mini-apps for on-set playback in TV and film. I have been tasked with trying to find a replacement, and although Animate CC seemed to be the most likely candidate, I don't think it is going to work"
Copy link to clipboard
Copied
I also am trying to find a director replacement and work out the kinks for on set playback using animate.
Copy link to clipboard
Copied
Have a sample of the video to test with? I haven't tried in a bit but I've gotten video to loop seamlessly, (at least that's what I remember), by using a cue point near the last frame, and listening for that instead of NetStream.Play.Stop which the flv player does. And then you're listening for it to throw a complete... that'll never be seamless.
Also, I'd say there is no better replacement for Director than Animate. Unity is good, but Animate has much better UI tools, Bitmap tools, etc. There's nothing Director can do that Animate can't do better these days. And Lingo compared to AS3... no comparison. Lingo sucks.
Copy link to clipboard
Copied
I've been dealing with this for years...the solution to get rid of the black is to do a quick screenshot at the end of the video, write that to the stage, then seek. Also works with switching videos...do a screen grab, put that on stage, then switch. Still a few frames of still image before the new feed starts but it's better than black.
Copy link to clipboard
Copied
The only way you can get a truly seamless video loop is to encode the video as FLV and play it from the timeline.
Copy link to clipboard
Copied