Solved

Loop FLV without slowing down computer

Posted on 2009-05-07
7
282 Views
Last Modified: 2013-11-11
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

0
Comment
Question by:mingchih
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 24326422

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


rp / ZA

0
 

Author Comment

by:mingchih
ID: 24327583
no.... it was only like 5% before playing the flash
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24327794

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

rp / ZA
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:mingchih
ID: 24327915
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
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24327995
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
0
 

Author Comment

by:mingchih
ID: 24328070
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);
      }
};
0
 
LVL 22

Accepted Solution

by:
rascalpants earned 500 total points
ID: 24436010

sorry for the delay on the response... must has slipped through the cracks...


I would try these onStatus info codes instead of "NetStream.Play.Stop"

NetStream.Buffer.Flush
NetStream.Buffer.Empty


this is normally what gets passed when a FLV has finished streaming...


rp / ZA


0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now