streaming video via a wrapped netstream, netConnection objects in an instance of the class below (this is a base class for an inherited sequenec of video players...please feel free to use it if you want)
Simply using this and setting the bufferTime doesnt work it waits for the file to download in its entirity before playing! It works fine locally and through the bandwidth profiler just not online!
I have narrowed it down to the BufferTime but cant see why it isnt using it...as it traces as being set
If i rip ot out and craete the netConnection and netStream on the timeline it works fine....but it should work like this!!!
Any pointers would be graetly appreciated
Thanks Jon
Frame code:
Code:
var myVideo:BasicVideoPlayer=new BasicVideoPlayer(videoElement)
myVideo.setBuffer(5)
myVideo.loadVideo("video1.flv"
this.createTextField("buffer_txt", this.getNextHighestDepth(), 10, 10, 300, 22);
buffer_txt.html = true;
var buffer_interval:Number = setInterval(checkBufferTime, 100, myVideo._netStream);
function checkBufferTime(my_ns:NetStream):Void {
var bufferPct:Number = Math.min(Math.round((my_ns.bufferLength/my_ns.bufferTime)*100), 100);
var output_str:String = "<textformat tabStops='[100,200]'>";
output_str += "Length: "+my_ns.bufferLength+"\t"+"Time: "+my_ns.bufferTime+"\t"+"Buffer:"+bufferPct+"%";
output_str += "</textformat>";
buffer_txt.htmlText = output_str;
}
CLASS:
Code:
class BasicVideoPlayer
{
public var _myVideo:Object
public var _netStream:NetStream
public var _nc:NetConnection
public var _metaObject:Object
function BasicVideoPlayer(videoElement:Object)
{
_myVideo=videoElement
_nc=new NetConnection()
_nc.connect(null);
_netStream = new NetStream(_nc);
_myVideo.attachVideo(_netStream);
_metaObject=new Object()
}
public function loadVideo(fileName:String):Void
{
_netStream.fileName=fileName
_netStream.onMetaData = function(infoObject:Object)
{
_metaObject=infoObject
this.totalTime = infoObject.duration
}
playVideo()
}
public function setBuffer(buffTime:Number):Void
{
_netStream.setBufferTime(buffTime);
}
public function clearVideo():Void
{
_netStream.clear()
_myVideo.clear()
}
public function playVideo():Void
{
_netStream.play(_netStream.fileName)
}
public function stopVideo():Void
{
_netStream.pause()
}
public function getCurrentTime():Number
{
return _netStream.time
}
public function getDuration():Number
{
return _netStream.totalTime
}
public function getFPS():Number
{
return _netStream.currentFps;
}
}