Hello all,
I have a fully working flv player using the netstream method.
I would like to display the total duration of the flv together with the amount that the video has currently played in a text field.
e.g. 1.21 / 4.23
How may i go about doing this?
I’m using Flash 8, Actionscript 2.0.
My code is:
[LEFT]var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
ns.setBufferTime(10);
ns.onStatus = function(info) {
trace(info.code);
if(info.code == "NetStream.Buffer.Full") {
bufferClip._visible = false;
}
if(info.code == "NetStream.Buffer.Empty") {
bufferClip._visible = true;
}
if(info.code == "NetStream.Play.Stop") {
ns.seek(0);
}
}
ns.play("http://idl.newport.ac.uk/einclusion/flash/PEOPLEoverview_movie.flv");
playPause.onRollOver = function()
{
if(this._currentframe == 1)
this.gotoAndStop('pauseOver');
else this.gotoAndStop('playOver');
}
playPause.onRollOut = function()
{
if(this._currentframe == 10) this.gotoAndStop('pause');
else this.gotoAndStop('play');
}
playPause.onRelease = function() {
if(this._currentframe == 10)
{
this.gotoAndStop('playOver');
this._parent.ns.pause();
}
else
{
this.gotoAndStop('pauseOver');
this._parent.ns.pause();
}
}
rewindButton.onRelease = function() {
ns.seek(0);
}
var videoInterval = setInterval(videoStatus,100);
var amountLoaded:Number;
var duration:Number;
ns["onMetaData"] = function(obj) {
duration = obj.duration;
}
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * 328.9;
loader.scrub._x = ns.time / duration * 328.9;
}
var scrubInterval;
loader.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false,0,this._y,328,this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus,100);
this.stopDrag();
}
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/328)*duration));
}[/LEFT]
All help will be appreciated as I have been trying to find a solution for this for quite some time now!
Regards
EGR103