Solved

Changing the framerate playback of VideoFile in AS3 / Air App

Posted on 2008-10-13
2
532 Views
Last Modified: 2013-11-11
Hi, I'm trying to reproduce a video file using AIR.

I'm trying to set the framerate of the playback using the import flash.net.NetStream and flash.media.Video, specifically the NetStream.receiveVideoFPS(fps:Number) but it is not working.

Please help,

Thanks.





package etc.patexp
{
	import flash.display.Sprite;
	import flash.events.NetStatusEvent;
	import flash.events.SecurityErrorEvent;
	import flash.events.AsyncErrorEvent;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.media.Video;
	
	
	/**
	 * ...
	 * @author Daniel Rodriguez
	 */
	public class Main extends Sprite 
	{
		
		private var videoURL:String = "video.flv";
        private var connection:NetConnection;
        private var stream:NetStream;
		
        public function Main():void
		{
            connection = new NetConnection();
            connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            connection.connect(null);
        }
 
        private function netStatusHandler(event:NetStatusEvent):void 
		{
            switch (event.info.code) 
			{
                case "NetConnection.Connect.Success":
					stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
                    connectStream();
                    break;
                case "NetStream.Play.StreamNotFound":
                    trace("Unable to locate video: " + videoURL);
                    break;
            }
        }
		
        private function connectStream():void 
		{
            stream = new NetStream(connection);
            stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
			stream.client = new CustomClient();
            var video:Video = new Video();
            video.attachNetStream(stream);
            stream.play(videoURL);
            addChild(video);
        }
		
		
 
        private function securityErrorHandler(event:SecurityErrorEvent):void 
		{
            trace("securityErrorHandler: " + event);
        }
        
        private function asyncErrorHandler(event:AsyncErrorEvent):void 
		{
            // ignore AsyncErrorEvent events.
        }
		
		private function onKeyDown(evt:KeyboardEvent):void
		{
			stream.receiveVideoFPS(0);
		}
		
	}
	
}
class CustomClient {
    public function onMetaData(info:Object):void {
        trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
    }
    public function onCuePoint(info:Object):void {
        trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);
    }
}

Open in new window

0
Comment
Question by:dornad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 22708384
As per my understanding,

NetStream.receiveVideoFPS() method works only for the Streaming server video stream.
this method is available only to clients subscribed to the specified stream, not to the stream's publisher.

If you pass a value to the FPS parameter to limit the frame rate of the video, the RTMP server attempts to reduce the frame rate while preserving the integrity of the video. The server sends the minimum number of frames needed to satisfy the desired rate between every two keyframes.

here in your code,  there is no RTMP server in play, your code is not actually connecting to any Media server.
following line of code shows that you are loading video as progressive download not streaming download.

 connection.connect(null);


I hope it would be clear..

-------------------
Aneesh Chopra
-------------------



0
 

Accepted Solution

by:
dornad earned 0 total points
ID: 22711249
Ohhhh.....

Funny, cause I'm not using a Streaming Video Server.  I'm just loading the file from the local hard disk.   All I need to do is slow-down or speed-up the video ?  

I thought that using fps would be the way to go here.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Flash Player White Screen Facebook 5 789
free flash maker 5 222
How  to reduce the .AVI file size of 90GB 4 372
Adobe Flash Install via GPO - Remove Prior Versions From GPO? 1 172
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

749 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