Skip to main content
Inspiring
September 17, 2008
Question

exit out of video and return to stage frame 1

  • September 17, 2008
  • 1 reply
  • 217 views
Ive manged to create a flash player that incorporates a video using a online
tutorial with the code below.

All is working well but at the end of the video I want to exit out of the
video and return to the stage at frame 1. The reason being is; before a user
hits play an interface image (containing info) is displayed. When they hit
the play button the video appears and plays over the interface image.
problem is at the end of the video the layer containing the image is still
covered by the video. when the video finishes I need a line of code to exit
and return the player to the original state without the presecence of the
video layer.

any ideas? thanks in advance

Brett


var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);

theVideo.attachVideo(ns);

rewindButton.onRelease = function() {
ns.seek(0);
ns.play();
}

playButton.onRelease = function() {
ns.play("modular.flv");
}

pauseButton.onRelease = function() {
ns.pause();
}

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 * 200;
loader.scrub._x = ns.time / duration * 200;
}

var scrubInterval;

loader.scrub.onPress = function(){
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit, 10);
this.startDrag(false,1,this._y,198,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/200)*duration));
}


This topic has been closed for replies.

1 reply

Inspiring
September 19, 2008
Inside the videoStatus() function Check the Current Time and Total time for video completion. Some time the Video doesn't have exact Time when comparing to the Total duration so use Math.floor to compare. if you still facing problem also check the Buffer status and Video status too.