Flv player
hi rananjay is here. try this script....
// flv player..
// developer.. Rananjay Singh
// video instance name = thevideo
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
the_video.attachVideo(ns);
ns.play("vegas.flv");
//made control on new layer button name = Rewind button,play button
rewindbutton.onRelease = function() {
ns.seek(0);
};
playbutton.onRelease = function() {
ns.pause();
};
//loader..
// made new symbol named loader with strock
// inside this select the fill color & make new mc named loadbar
var videoInterval = setInterval(videstatus, 100);
var amountloaded:Number;
function videostatus() {
amountloaded = ns.bytesLoaded/ns.bytesTotal;
loader.loadbar._width = amountloaded*217.9;
// 217.9___ width of loadbar
}
// flv setting-- framerate = 1.1,,, frame every 30
// make anew mc for seekbar named scrub
// then it place on loadbar
var duration:Number;
ns["onMetaFata"] = function (obj) {
duration = obj.duration;
loader.scrub._x = ns.time/duration*208.9;
//208.9 width of loadbar
};
// scrubbar firs see what area cover loadbar 0 to x
var scrubInterval;
loader.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit, 10);
this.startDrag(false, 0, this._y, 208, this._y);
};
loader.scrub.onRelease = function() {
clearInterval(scrubInterval);
videoInterval = setInterval(videstatus, 100);
this.stopDrag();
};
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/208)*duration));
}
//buffering---- made a videosize blackmc & inside that give text alpha animation,, named buffer
ns.setBufferTime(30);
ns.onStatus = function(info) {
//if(info.code ==)..... see netstream class in help & compleate it
};
// custom ontextmenu..
var themenu:ContextMenu = new ContextMenu();
themenu.hideBuiltInItems();
_root.menu = themenu;
var i1:ContextMenuItem = new ContextMenuItem("video controls", trace);
var i2:ContextMenuItem = new ContextMenuItem("play/pause video", pauseit);
var i3:ContextMenuItem = new ContextMenuItem("replay video", replayit);
var i4:ContextMenuItem = new ContextMenuItem("copy right", trace);
themenu.customItems[0] = i1;
themenu.customItems[1] = i2;
themenu.customItems[2] = i3;
themenu.customItems[3] = i4;
// after that create two functions for context menu
function pauseit() {
ns.pause();
}
function replayit() {
ns.seek(0);
}
// and now prepratin foe volume control
//make a four stage movi clip for sound .. named normal,onover,mute , muteover
_root.createEmptyMovieClip("vsound", _root.getNextHighestDepth());
vsound.attachAudio(ns);
var so:Sound = new Sound(vsound);
so.setVolume(100);
// button name = mute
mute.onRollOver = function() {
if (so.getVolume() == 100) {
this.gotoAndStop("onover");
} else {
this.gotoAndStop("muteover");
}
};
mute.onRollOut = function() {
if (so.getVolume() == 100) {
this.gotoAndStop("normal");
} else {
this.gotoAndStop("mute");
}
};
mute.onRelease = function() {
if (so.getVolume() == 100) {
so.setVolume(0);
this.gotoAndStop("muteover");
} else {
so.setVolume(100);
this.gotoAndStop("onover");
}
};
×