Link to home
Start Free TrialLog in
Avatar of Brian Lin
Brian LinFlag for United States of America

asked on

Loop FLV without slowing down computer

Hi, experts

I have the following code that works pretty well. However, it slows down the computer and use almost 50% of CPU. I would like to ask how can I fix the problem so the looping does not slow down computer.

Cheers

B
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
purple_video.attachVideo(stream_ns);
stream_ns.play("purple_effects.flv");
 
 
stream_ns.onStatus = function(info) {
	if (info.code == "NetStream.Play.Stop") {
		stream_ns.seek(0);
	}
};

Open in new window

Avatar of rascalpants
rascalpants
Flag of United States of America image


does the CPU spike up to 50% even when you don't use the loop?


rp / ZA

Avatar of Brian Lin

ASKER

no.... it was only like 5% before playing the flash

is that the only code in the project?  maybe it is something else that is causing a memory leak...

rp / ZA
no, without that code, everything else runs fast and smooth..... with that code.... everything slow down :(

I wonder is it because the code keep streaming at every loop ? is it possible to have animation save in cache and run from cache ? if possible
well, my first thought, before I saw your code, was that you were creating a new instance in memory each time...  but Unless the seek method does this natively, I am not sure why this would be happening...

And normally when the video is streamed in, it is cached once it is loaded...  but it looks like you are using progressive download anyway...

have to look into this...  be back later


rp / ZA
I can also change to streaming too... progressive or streaming has same slow down computer result...

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect("rtmp://www.site.com/ondemand/media/flash/flv");
var stream_ns:NetStream = new NetStream(connection_nc);
purple_video.attachVideo(stream_ns);
stream_ns.play("purple_effects");


stream_ns.onStatus = function(info) {
      if (info.code == "NetStream.Play.Stop") {
            stream_ns.seek(0);
      }
};
ASKER CERTIFIED SOLUTION
Avatar of rascalpants
rascalpants
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial