Friday, November 30, 2012

Streaming a FLV video with AS3/Flash/Flex from a URL without a Streaming Server


Here's a code snippet to stream a FLV from a random source without a RTMP streaming server like Red 5/ FMS.

//You'll have to add the necessary imports

private var _video:Video; //Our video object

_video = new Video(640, 480);

private var _netConnection:NetConnection = new NetConnection();
_netConnection.connect(null); //No need of specifying a RTMP server!


private var _ns:NetStream = new NetStream(_netConnection);

_ns.addEventListener(NetStatusEvent.NET_STATUS, handleNetStatusPlay, false, 0, true);

_video.attachNetStream(_ns); //Attach our NetStream to our video object

_ns.client = new NetStreamUserClient(_ns);
var streamPath:String = "http://www.flvFilesSite.com/myFolder/myTestFLV.flv";
_ns.play(streamPath);



//Handle our NetStatusEvent
private function handleNetStatusPlay(e:NetStatusEvent):void
{

 if (e.info.level == "error")
 {
  if (e.info.code == "NetStream.Play.StreamNotFound")
  {
   trace("FLV file does not exist!");
  }
 }
}









Code for NetStreamUserClient
package
{
 import flash.net.NetStream;
 
 /**
  * ...
  * @author Rajesh Peter Douglas D'Monte
  */
 public class NetStreamUserClient
 {
  public function NetStreamUserClient()
  {
  }
  
  public function onCuePoint(infoObject:Object):void
  {
   trace("onCuePoint" + infoObject);
  }
  
  public function onMetaData(infoObject:Object):void
  {
   trace("onMetaData " + infoObject);
  }
  
  public function onPlayStatus(infoObject:Object):void
  {
   trace("onPlayStatus " + infoObject);
   //Debug.print_r(infoObject);
   if (infoObject.code == "NetStream.Play.Complete")
   {
    //FLV finished playing
   }
  }
 }
}
There are some formatting issues 'cause I haven't figured out how to display code properly on my blog.

Thursday, November 29, 2012

Super user (su) on Ubuntu Linux


This post is going to be very brief. I know a lot of you already know all this and more but I still have many friends who come and ask me how to access the Super User on Ubuntu Linux.

They tell me that it keeps asking them for a password and then the blessed thing doesn't seem to login with their password. This is because they have set a password for themselves but not the root, though sudo would work nicely but some chaps want to be fancy and go all su on Ubuntu.

So why does su not work with the password you set during Ubuntu's gui setup?
This is because the super user password is NOT set. I repeat is NOT set by you during Ubuntu's GUI installation. Is it blank? No! Some random password is set for security purposes.

Alright! So how the devil do you access su without going through some mucky cumbersome process of setting root's password.

Simple!

Go to the terminal (Ctrl + alt + T) (Default for Ubuntu Linux) and punch this in:

$ sudo su
[The system now prompts you for your user password. Enter it Einstein!]

Et voila! You are now in root in the current terminal session!


Note: This method still doesn't set super user's password.
Disclaimer: I am by no means an expert on Linux or the Unix family of operating systems. 'Nuff said.
Zoit: I am a n00b at Linux.