Groups | Blog | Home
all groups > flash actionscript > september 2007 >

flash actionscript : Need to loop an FLV


semx
9/5/2007 7:31:22 PM
Hi guys,

I have a movie player that uses custom code instead of components and all is
well. But now I need to loop the videos instead of just having them play
through and stop. Does anyone have a block of code that will pull that off?
My current code is attached.

Thanks!


var netConn:NetConnection = new NetConnection();
netConn.connect(null);
var ns:NetStream = new NetStream(netConn);
madison.attachVideo(ns);
ns.play("GUSA-29-TV30_flvsml.flv");
globalsound = new Sound();
globalsound.setVolume(0);
semx
9/6/2007 12:00:00 AM
chopTheWood
9/6/2007 1:35:25 AM
Here's a bunch of custom video controller code. You can probably get something
from it:

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

var ns:NetStream = new NetStream(nc);

theVideo.attachVideo(ns);

ns.setBufferTime(30);

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(vidPath);
//ns.play("http://www.portfolionewengland.com/interviews/rKukalis150.flv");

playButton.onRelease = function() {
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 * 208.9;
loader.scrub._x = ns.time / duration * 208.9;
}

var scrubInterval;

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

var theMenu:ContextMenu = new ContextMenu();
theMenu.hideBuiltInItems();
_root.menu = theMenu;

var item1:ContextMenuItem = new ContextMenuItem("::::: Video Controls
:::::",trace);
theMenu.customItems[0] = item1;

var item2:ContextMenuItem = new ContextMenuItem("Play / Pause
Video",pauseIt,true);
theMenu.customItems[1] = item2;

var item3:ContextMenuItem = new ContextMenuItem("Replay the Video",restartIt);
theMenu.customItems[2] = item3;

var item4:ContextMenuItem = new ContextMenuItem("? 2005 Lee
Brimelow",trace,true);
theMenu.customItems[3] = item4;

function pauseIt() {
ns.pause();
}

function stopIt() {
ns.seek(0);
ns.pause();
}

function restartIt() {
ns.seek(0);
}

_root.createEmptyMovieClip("vSound",_root.getNextHighestDepth());
vSound.attachAudio(ns);

var so:Sound = new Sound(vSound);

so.setVolume(100);

mute.onRollOver = function() {
if(so.getVolume()== 100) {
this.gotoAndStop("onOver");
}
else {
this.gotoAndStop("muteOver");
}
}

mute.onRollOut = function() {
if(so.getVolume()== 100) {
this.gotoAndStop("on");
}
else {
this.gotoAndStop("mute");
}
}

mute.onRelease = function() {
if(so.getVolume()== 100) {
so.setVolume(0);
this.gotoAndStop("muteOver");
}
else {
so.setVolume(100);
this.gotoAndStop("onOver");
}
}







stop();
chopTheWood
9/6/2007 1:51:49 AM
The following link gets you to a download page which includes an 8 part video
tutorial on making a custom video player (where I got this code) which will
explain about design and coding.

http://www.gotoandlearn.com/download.php
AddThis Social Bookmark Button