Skip to main content
Known Participant
October 3, 2012
Question

seamlessly looping FLVPlayback video no longer seamlessly looping

  • October 3, 2012
  • 4 replies
  • 28593 views

Hi,

 

Back in 2009 I created seamless video loops using the FLVPlayback component and 'addEventListener' (as3)—and they worked great!  looping round and round seamlessly—equally well in browsers as in flash. The videos were of varying lengths, small (all between 50—500K), and they looped perfectly.

Recently I've gone back to update things and noticed that my video loops are no longer seamlessly looping in any of the web browsers. Now there's a big pause interrupting the seamless flow.

 

  ??? why?  Has something in the delivery (browsers/flashplayer) changed?  All my video loops still run seamlessly when tested in Flash (CS5).  I spent a good amount of time investigating various angles but could not find any solution.

 

  Anyhow, here's the actionscript:

 

  stop();

 

  import fl.video.*;

 

  toggleButton.addEventListener(MouseEvent.MOUSE_OVER, rolloverToggle);

  toggleButton.addEventListener(MouseEvent.MOUSE_OUT, rolloutToggle);

  toggleButton.addEventListener(MouseEvent.CLICK, toggleClick);

 

  toggleButton.buttonState = "off";

      function rolloverToggle(event:MouseEvent):void {

      toggleButton.gotoAndStop(toggleButton.buttonState+" over");

      }

      function rolloutToggle(event:MouseEvent) {

      toggleButton.gotoAndStop(toggleButton.buttonState);

      }

      function toggleClick(event:MouseEvent):void {

          if (toggleButton.buttonState == "on") {

              toggleButton.buttonState = "off";

         vid_16_monty.pause();

          }else {

              toggleButton.buttonState = "on";

         vid_16_monty.play();

      vid_16_monty.addEventListener(VideoEvent.COMPLETE, rewind);

      function rewind(event:VideoEvent) {

         vid_16_monty.play();

          }

                }

          toggleButton.gotoAndStop(toggleButton.buttonState+" over");

      }

 

 

the video that goes with the above script can be viewed here:  http://www.designfail.us     cat should be in seamless motion... but it's not.

Also, not sure it would make much difference, but I'd be happy to attach an fla file—Adobe says it's a good idea but nowhere do they tell you how to attach an fla file... very peculiar, especially in these emphatic UI/UX times we live in.

This topic has been closed for replies.

4 replies

Inspiring
June 19, 2019

Just use com.greensock.loading.VideoLoader. Set repeat:-1 in the initialisation vars

Loops seamlessly. Tested with AIR 30.0

video = new VideoLoader("Movies/MyMovie.mp4", {repeat:-1, name:"myVideo", container:this, width:1280, height:800, scaleMode:"proportionalInside", bgColor:0x000000, autoPlay:false, volume:0, estimatedBytes:75000});

//start loading

video.load();

//to play

video.playVideo();

//to pause

video.pauseVideo()

Problem solved. No more self-made video Class extensions needed either. All the events you need built in. Phew.

Known Participant
March 12, 2014

I'm going to reply with some code that has worked for a simple loop for me. I'm not as experienced at AS3 as some, but here goes.  My videos have a fraction of a second where they are relatively still and I am using that point to make the move, but with some experimenting, it may work elsewhere, and perhaps it could be optimized:

import fl.video.FLVPlayback;

import fl.video.VideoEvent;

myvideo.addEventListener(fl.video.VideoEvent.PLAYHEAD_UPDATE, onPlayhead);

function onPlayhead(event: fl.video.VideoEvent):void {

    if (event.playheadTime < 7.75) return;    //do nothing until just before 8-second clip ends

    myvideo.pause();  //so it won't blink

    myvideo.seek(0);

    myvideo.play();

}

Essentially, I have an 8 second looping video.  PLAYHEAD_UPDATE fires every .25 of a second. So I watch it until it hits about a quarter second before the end of the video (7.75 seconds), and when it does, pause, seek and play again.  I think the pause is important to prevent the 'blink' that I was getting.  It might require adding a bit of dead space or repeated frames to the end of your clip to work optimally, since I find that once COMPLETE fires, playing back again causes a blink.  Speak up if it works / doesn't on your side, I'd like to know.

Meanwhile, I voted on the bugreport too.

sinious
Legend
March 17, 2014

Keeping away from COMPLETE will be important, you can't stop it internally from its behavior. Also if the video exceeds the in-memory buffer you might not be able to loop so seamlessly (e.g. 60 seconds of video). I found setting a keyframe on the time you wish to jump helps with the flicker as well (easy to set in most encoders).

That said, is this a website? As it's pretty obvious most sites are correcting their old ways of abusing the Flash platform for doing simple things like video playback, you could use a .mp4 in a HTML5 video tag with the loop attribute to seamlessly loop. That's of course if your needs are simple, like a page full of looping videos for sale.

Known Participant
March 18, 2014

No, it's for an iOS app.  I had to abandon FLVPlayback, I could not get it to play an mp4 on iOS, though it would play flv's but slowly.  I've moved to netstream and stagevideo, which is blazing fast, even with full HD.  But stagevideo is competing with my other use of stage3D, so it isn't as simple as I'd like.  Here's my stagevideo looping code, I hope it makes sense, I don't have time to nicen it up tonight.  There's more to it, but if you set up a video using NetStream and stagevideo, this should work.

function onEnterFrame(e:Event):void

{

    var current_time :Number = mynetstream.time;

   

    if (!stream_paused) //my own boolean

    {

        if( current_time > (video_duration-0.1) )  //almost at the end of the clip

        {            

            mynetstream.pause();

            stream_paused = true;

            mynetstream.seek(0);

        }       

    }

    else

    {

        if (current_time < 0.1) //i.e. = 0

        {           

            mynetstream.resume();

            stream_paused = false;       

        }

    }

}

function onMetaData(mynetstream_data:Object):void

{

    video_duration = mynetstream_data.duration;  

}

Inspiring
March 8, 2013

Another option is to import the video, choosing to embed it as a movieclip. You could load the swf(s) with embedded video/movieclip as needed. Here's an example: http://www.chrismanuel.ca/testing/looptest.html. Since the goal is to loop short clips you won't need to stream anything which circumvents the issues with the netstream class and looping.

Participating Frequently
March 14, 2013

Hey folks!

Adobe finally reproduced this issue. Now they closed the Bugreport as deferred....

As long as there are no other votes on it, they willnot try to fix this bug.

Please vote for it! Here is the BugReport:

https://bugbase.adobe.com/index.cfm?event=bug&id=3349340

sinious
Legend
October 3, 2012

Not sure at all what flash player you ever saw an external FLV loop seamlessly on but it's been my vast overwhelming experience that it just cannot do that. Never has.

The only way I ever got FLVs to loop seamlessly was placing them on the timeline. Otherwise there was always a studder when the playhead hit the end and seek(0)'d (same as just throwing it a new play() which is what your rewind() is doing).

Depending on what you're doing you could try alternatives like StageVideo. It may handle the loop a bit better although I doubt it.

Also, that delay is pretty big. Even back in the AS2 FLVPlayback days the delay was nowhere near what I'm seeing. You might want to consider adding in a AS cuepoint while trying to seek(0). I've never had that much loop delay.

montysMAuthor
Known Participant
October 3, 2012

thanks for the reply Sinious,

I've encountered the opinion that it's just not possible (except timeline). But it is. Or perhaps I should say was. And hopefully still is...

There's plenty of sites/forums where the FLVPlayback/addEventListener method is detailed in creating seamless flv loops.  In my recent traipse through the interwebs though, they all seem to be dated around 2007-2010...

I do know it's possible (or at least was) because I and other people have seen it work. Tested on all major browsers, PC/mac, and all the vids played back seamlessly.  Otherwise I would not have published it: http://www.octopistudio.com/OS_Web01_4ourX5ive.html

It looks like crap now, but you can imagine it playing back seamlessly...

I do agree with you that the delay is big.  Even more so for something that used to run seamlessly... with AS3. 

I am seriously baffled why something that used to work no longer does.  It seems like Flash should be getting better, not worse.

I've read about the cuepoints, but from what I've read they don't seem to create a  seamless loop.  It needs to be seamless.

Participating Frequently
December 14, 2012

bug report, Adobe Flash Player 11.0  -  Bug 3349340   - 

is here:

https://bugbase.adobe.com/index.cfm?event=bug&id=3349340

it's an election year, so go vote!


Hey folks!

I finally found a workaround for this issue after some time of trying... Simply embed a Cuepoint to the very end of the FLV and listen to that instead of the EndOfStream- / Complete-Event.

(Unfortunately you cannot use "addASCuePoint" (or a similar method) with the netstream object)

Here is the Code:

var customClient : Object = new Object();

customClient.onCuePoint = function(infoObject : Object):void {

     trace("Found CuePoint. Resetting video to start...")

     ns.seek(0);

     ns.play();

};

ns.client = customClient;

Works fine for me. I hope this is helpful for you!

Best wishes!

Message was edited by: caa_sion