<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Not sLop &#187; flash</title>
	<atom:link href="http://www.walking-productions.com/notslop/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.walking-productions.com/notslop</link>
	<description>Not - Shawn's Little Outpost</description>
	<lastBuildDate>Fri, 23 Dec 2011 15:23:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Open for Business</title>
		<link>http://www.walking-productions.com/notslop/2010/05/15/open-for-business/</link>
		<comments>http://www.walking-productions.com/notslop/2010/05/15/open-for-business/#comments</comments>
		<pubDate>Sat, 15 May 2010 14:21:46 +0000</pubDate>
		<dc:creator>vanevery</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[future]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[New York City]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[Related to this Site]]></category>
		<category><![CDATA[Streaming and Multi-Media]]></category>
		<category><![CDATA[telephony]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[VoIP]]></category>
		<category><![CDATA[mobile sms itv ebif mobileweb android iphone streaming flash]]></category>

		<guid isPermaLink="false">http://www.walking-productions.com/notslop/?p=1722</guid>
		<description><![CDATA[Walking Productions provides software development and consulting services. Appealing projects are those that deal with online and mobile media (audio/video). Get in touch: vanevery@walking-productions.com Android Application Development Flash Video Players, including P2P (Adobe Stratus) Wowza Media Server Plugin/Module Development Flash &#8230; <a href="http://www.walking-productions.com/notslop/2010/05/15/open-for-business/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Walking Productions provides software development and consulting services. Appealing projects are those that deal with online and mobile media (audio/video).  Get in touch: <a href="mailto:vanevery@walking-productions.com">vanevery@walking-productions.com</a></p>
<p>Android Application Development<br />
Flash Video Players, including P2P (Adobe Stratus)<br />
Wowza Media Server Plugin/Module Development<br />
Flash Media Server Development<br />
Development related to Axis IP Cameras<br />
QuickTime/Darwin Streaming Solutions<br />
Audio and Video Encoding/Transcoding Pipelines<br />
iPhone Application Development<br />
JME/J2ME Application Development<br />
Asterisk and VoIP Application Development<br />
Phone call to streaming applications<br />
Voicemail to Blog/CMS<br />
Podcasting Systems<br />
Mobile and Microblogging Solutions<br />
SMS Campaign Management Software<br />
2 Screen Interactive Television Applications (Enhanced TV)<br />
EBIF iTV Application Development<br />
HTML 5 Video Player Development<br />
Media Asset Management Systems<br />
AJAX/JavaScript/DHTML Development<br />
LAMP Application Development (Linux, MySQL, PHP)<br />
Java Desktop Application Development<br />
Mobile Video Capture, Sharing and Playback Applications<br />
Live Mobile Video Streaming<br />
Computer Vision Applications in Java and Flash<br />
Flash Video Capture<br />
Location Aware Mobile Applications<br />
Video Indexing, Searching, Recommendation Engine and Presentation Systems<br />
Network Controlled Devices<br />
WordPress and Drupal Plugin/Module Development<br />
Flash Lite Application Development<br />
AIR/ActionScript 3 Application Development<br />
WebService Integration and Development (XML-RPC, SOAP, REST)<br />
Podcasting (Audio/Video) Solutions<br />
MP3 Streaming Servers<br />
MMS Gateway Solutions<br />
Java and AJAX Chat Application Development<br />
Interactive Whiteboard Applications</p>
]]></content:encoded>
			<wfw:commentRss>http://www.walking-productions.com/notslop/2010/05/15/open-for-business/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Media Server Sending Images</title>
		<link>http://www.walking-productions.com/notslop/2009/12/02/flash-media-server-sending-images/</link>
		<comments>http://www.walking-productions.com/notslop/2009/12/02/flash-media-server-sending-images/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 16:19:41 +0000</pubDate>
		<dc:creator>vanevery</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Streaming and Multi-Media]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bitmapdata]]></category>
		<category><![CDATA[flashmediaserver]]></category>
		<category><![CDATA[fms]]></category>
		<category><![CDATA[frame]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[sharedobject]]></category>
		<category><![CDATA[snapshot]]></category>
		<category><![CDATA[streaming]]></category>

		<guid isPermaLink="false">http://www.walking-productions.com/notslop/?p=1690</guid>
		<description><![CDATA[One of my students in my live web class is developing an interesting application that sends screenshots to other people. I put together some sample code to help him along and thought this would be of general interest. Using the &#8230; <a href="http://www.walking-productions.com/notslop/2009/12/02/flash-media-server-sending-images/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of my students in my <a href="http://itp.nyu.edu/~sve204/liveweb_fall2009">live web class</a> is developing an interesting application that sends screenshots to other people.  I put together some sample code to help him along and thought this would be of general interest.</p>
<p>Using the Flash Media Server with Remote Shared Objects this can be built.  Here is a walk through of the code:</p>
<p>First of all, this uses the JPGEncoder class from the <a href="http://code.google.com/p/as3corelib/">AS3CoreLib</a> so you probably want to grab that and import it.</p>
<pre>
	import com.adobe.images.JPGEncoder;
</pre>
<p>This example uses a SharedObject, a NetConnection and NetStreams for sending the video as well as the screen shots.  Once the NetConnection is established, the SharedObject can be setup:</p>
<pre>
        // Listener for connection
        private function connectionHandler (e:NetStatusEvent):void
        {
        	// If we are connected
             if (e.info.code == "NetConnection.Connect.Success")
             {
				// Set up the shared object
				// We'll call it SimpleSO, pass in the app url and not make it persistent
				sharedObject = SharedObject.getRemote("SimpleSO",nc.uri,false);

				// Tell the shared object to call methods in this class if requested
				sharedObject.client = this;				

				// Add a listener for when shared object is changed
			   	sharedObject.addEventListener (SyncEvent.SYNC,syncEventCallBack); 

				// Connect the shared object to our netConnection
				sharedObject.connect(nc);

				// All of the video streaming setup
				doEverything();

				// Register mouseclicks, how we'll determine when to send a frame
				stage.addEventListener(MouseEvent.MOUSE_DOWN, saveFrame);
             }
        }
</pre>
<p>Here is the method that is called when the mouse is clicked.  It creates a bitmapdata object, encodes as a JPEG and sends that as a bytearray through the shared object:</p>
<pre>
        private function saveFrame(e:MouseEvent):void
        {
        	// Save the frame to the bitmapdata object
        	var bmpd:BitmapData = new BitmapData(320,240);
        	bmpd.draw(videoIn1);

        	// First encode as JPEG so it is smaller
			var jpgEncoder:JPGEncoder = new JPGEncoder(100);
			var jpgByteArray:ByteArray = jpgEncoder.encode(bmpd);

			// Send it via the shared object
			sharedObject.send("newBitmap",jpgByteArray);
        }
</pre>
<p>The SharedObject.send method calls the function &#8220;newBitmap&#8221; on everyone who is connected and passes in the jpgByteArray.  The newBitmap function uses the Loader to uncompress the JPG and when it is done calls &#8220;gotBitmapData&#8221;:</p>
<pre>
		public function newBitmap(jpgByteArray:ByteArray):void
		{
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, gotBitmapData)
			loader.loadBytes(jpgByteArray);
		}
</pre>
<p>gotBitmap data just creates a regular Bitmap and displays it:</p>
<pre>
	private function gotBitmapData(e:Event):void
	{
		var decodedBitmapData:BitmapData = Bitmap(e.target.content).bitmapData

        	// Create the bitmap image
        	var bmp:Bitmap = new Bitmap(decodedBitmapData);

        	// Add it to the stage
        	bmp.x = 0;
        	bmp.y = 240;
        	addChild(bmp);
	}
</pre>
<p>Here is the full AS3 class (it could be improved but it works):</p>
<pre>
package
{
	// Import JPEGEncoder Class from: http://code.google.com/p/as3corelib/
	import com.adobe.images.JPGEncoder;

	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.events.NetStatusEvent;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.media.Camera;
	import flash.media.Microphone;
	import flash.media.Video;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.MouseEvent;
	import flash.utils.ByteArray;
	import flash.net.SharedObject;
  	import flash.events.SyncEvent;
  	import flash.events.Event;
	import flash.display.Loader;

	public class VideoCapture extends Sprite
	{
		// Shared Object for communication
   		private var sharedObject:SharedObject;

 		// Overall NetConnection for communicating with FMS
        private var nc:NetConnection; 

        // RTMP URL, same as directory on FMS
        private var rtmpURL:String = "rtmp://xxxx/webcam";

        // NetStreams for each stream
        private var netStreamOut:NetStream;
        private var netStreamIn1:NetStream; 

        // Camera
        private var camera:Camera;
        // Microphone
        private var microphone:Microphone; 

        // My Video
        private var videoOut:Video; 

        // Video Components
        private var videoIn1:Video; 

        // Stream Names
        private var outStream:String;
        private var inStream1:String; 

        public function VideoCapture()
        {
        	// Construct NetConnection and connect to server
             nc = new NetConnection();
             nc.connect(rtmpURL); 

             // Add a listener for connection
             nc.addEventListener (NetStatusEvent.NET_STATUS,connectionHandler);
        } 

        // Listener for connection
        private function connectionHandler (e:NetStatusEvent):void
        {
        	// If we are connected
             if (e.info.code == "NetConnection.Connect.Success")
             {

				// Set up the shared object
				// We'll call it SimpleSO, pass in the app url and not make it persistent
				sharedObject = SharedObject.getRemote("SimpleSO",nc.uri,false);

				// Tell the shared object to call methods in this class if requested
				sharedObject.client = this;				

				// Connect the shared object to our netConnection
				sharedObject.connect(nc);

				// All of the video streaming
				doEverything();

				// Register mouseclicks, how we'll determine when to send a frame
				stage.addEventListener(MouseEvent.MOUSE_DOWN, saveFrame);
             }
        }

        // Gets the results from the server
        private function doEverything():void
        {
        	// Name of streams
			outStream="one";
			inStream1="one"; 

			// Setup the camera
			camera = Camera.getCamera(); 

			// setup the microphone
			microphone = Microphone.getMicrophone(); 

			// Video components
			videoOut = new Video();
    		videoIn1 = new Video();

			// Set positions
			videoOut.x = 0;
			videoOut.y = 0;
			videoIn1.x = 320;
			videoIn1.y = 0;

			// Add them to the screen
			addChild(videoOut);
			addChild(videoIn1);

            // Publish our stream
            netStreamOut = new NetStream(nc);
            netStreamOut.attachAudio(microphone);
            netStreamOut.attachCamera(camera);
            netStreamOut.publish(outStream, "live"); 

            // Attach camera to our video
            videoOut.attachCamera(camera); 

            //Play incoming streamed video
            netStreamIn1 = new NetStream(nc); 

			videoIn1.attachNetStream(netStreamIn1);

			netStreamIn1.play(inStream1);
        }

        private function saveFrame(e:MouseEvent):void
        {
        	// Save the frame to the bitmapdata object
        	var bmpd:BitmapData = new BitmapData(320,240);
        	bmpd.draw(videoIn1);

        	// First encode as JPEG so it is smaller
			var jpgEncoder:JPGEncoder = new JPGEncoder(100);
			var jpgByteArray:ByteArray = jpgEncoder.encode(bmpd);

			// Send it via the shared object
			sharedObject.send("newBitmap",jpgByteArray);
        }

		public function newBitmap(jpgByteArray:ByteArray):void
		{
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, gotBitmapData)
			loader.loadBytes(jpgByteArray);
		}

		private function gotBitmapData(e:Event):void
		{
			var decodedBitmapData:BitmapData = Bitmap(e.target.content).bitmapData

        	// Create the bitmap image
        	var bmp:Bitmap = new Bitmap(decodedBitmapData);

        	// Add it to the stage
        	bmp.x = 0;
        	bmp.y = 240;
        	addChild(bmp);
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.walking-productions.com/notslop/2009/12/02/flash-media-server-sending-images/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

