July
---
2003




Streaming Flash Video in Windows Executable.

This experiment simply tries to use the streaming video capabilities of Flash with a C# desktop software app shell or, in other words, a good ol' executable.

The app will show 6 files.

  • 3 files will use the loadMovie() method
  • 3 files will use the netStream() method

The loadMovie() method simply loads a swf file, located on the local machine into the video window. The movie is streaming but from a file on your local machine.

The netStream() method truly streams the video from files located on a remote server using Flash Communication server.

I am using a low, low bandwith account so the stream may hickup here and there. Video quality is poor. Please forgive me, but my intent is to demonstrate feasibility and not user satisfcation at this moment.

To use this simple app you must have these requirements:

  • Micorosoft .NET framework 1.1 installed. Get it here.
  • download the zip file below
  • unzip the three file on your desktop or anywhere else you prefer
  • doubleclick the videoTest1.exe file

Csharpvideo.zip (18kb)

This does not install anything on your computer. To remove, simply delete the folder or files. Also, make sure your firewall is not blocking the outgoing request, looking for the video stream on the server.

Note: if trying out the streaming video and the led turns red, it means that there are no connections available. Wait a few minutes for someone to release a connection and try again. I have only 5 connections and if those are used, no one else can connect untill someone leaves.

as code

#include "NetDebug.as"

Movieclip.prototype.checkDomain=function(validDomain){
    var urlString=this._url;
    
    var part1=urlString.indexOf("://")+3;
    var part2=urlString.indexOf("/", part1);
    var cdomain=urlString.substring(part1,part2);

    var part3=cdomain.lastIndexOf(".")-1;
    var part4=cdomain.lastIndexOf(".", part3)+1;
    var cdomain = cdomain.substring(part4, cdomain.length);
    
    if(cdomain == validDomain){
        return(true);    
    }
}

client_nc = new NetConnection();
rlight.connect(client_nc);

if(this.checkDomain("domain.com")){
    client_nc.connect("rtmp:/videlotest");
    client_nc.onStatus = onconnect;
}else{
    alert("This is not a valid domain...");    
}

function onconnect(returnObj) {
    if (returnObj.code == "NetConnection.Connect.Success") {
        RunClip();
    }else{
        alert(returnObj.code);    
    }
}

function RunClip(){
    myInputStream_ns = new NetStream(client_nc);
    vidBoxPlay.attachVideo(myInputStream_ns);
    myInputStream_ns.setBufferTime(1);
    myInputStream_ns.play("test1",0,-1,true);
    getTime = setInterval(getTimeFunc, 1);    
}

function getTimeFunc(){
    timer.text = myInputStream_ns.time;
}


//------------------------------------------------------------
function alert(retval){
    if (_root._url.substr(0,4)=="file"){
        trace (retval);
    } else {
        getURL ("javascript:alert('" + retval + "')");
    }
}