Hi All,
[COLOR=#003366]I am back with a problem in my first posting here and need your help guys.[/COLOR]
[COLOR=#003366]
I am working on a FLV-XML Playlist and everything is working on fine.[/COLOR]
[COLOR=#003366]Here I want to add 2 buttons PREVIOUS and NEXT (already there in the flash that I have attached), when clicked it will just play the Next/Previous video from its current location.[/COLOR]
[COLOR=#003366]That means it does not matter whether the presently running video has ended its play or not, whenever I will click on the previous/next, the next video will play and so on.[/COLOR]
[COLOR=#003366]I have uploaded the XML and the Flash also. Can anyone please help me out on this? [/COLOR]
[COLOR=#003366]
Appreciating you kind help.
================================
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
ns.setBufferTime(10);
ns.onStatus = function(info) {
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);
//var t = videoList.selectedIndex+1;
//if (t<videoList.length) {
//ns.play(videoList.getItemAt(t).data);
//videoList.selectedIndex = t;
//}
}
}
playButton.onRelease = function() {
ns.pause();
};
rewindButton.onRelease = function() {
ns.seek(0);
};
forward.onRelease=function(t){
//ns.seek(0);
var t = videoList.selectedIndex + 1;
if (t < videoList.length) {
ns.play(videoList.getItemAt(t).data);
videoList.selectedIndex = t;
}
};
this.createEmptyMovieClip(“vFrame”, this.getNextHighestDepth());
vFrame.onEnterFrame = videoStatus;
var amountLoaded:Number;
var duration:Number;
ns[“onMetaData”] = function (obj) {
duration = obj.duration;
};
function videoStatus() {
amountLoaded = ns.bytesLoaded/ns.bytesTotal;
loader.loadbar._width = amountLoaded208.9;
loader.scrub._x = ns.time/duration208.9;
//trace (duration);
//trace (amountLoaded);
//trace (ns.time);
//timePlayed=Math.round (ns.time);
seconds=Math.floor(ns.time%60);
//playSec=seconds;
minute=Math.floor(ns.time/60);
//duration=Math.floor(ns.time%60);
playSec=":" + seconds;
playMin=“0” + minute;
//Calculating the Total Duration Time, Starts Here
totalDuration=Math.round (duration);
if (duration>60 && duration<120){
totalDurationmin=“01” + “:”;
totalDurationsec=Math.round(duration-60);
}if(duration<60){
totalDurationmin=“00” + “:”;
totalDurationsec=Math.round(duration);
}
//Calculating the Total Duration Time, Ends Here
//}else if(tpSeconds>=60){
//timePlayed=tpMinute + “0” + tpSeconds;
//}
/duration_seconds=Math.floor(duration%60);
duration_minute=Math.floor(duration_seconds/60);
if(duration_seconds<60){
totalDuration=“00:” + duration_seconds;
//totaltimeDisplay=Math.round (ns.time) + " / " + Math.round (duration) + " secs";
}if(duration_seconds>60){
totalDuration=“0” + “1” + “0” + duration_seconds;
}/
}
/var time_interval:Number = setInterval(checkTime, 500, stream_ns);
function checkTime(ns:NetStream) {
var ns_seconds:Number = ns.time;
var minutes:Number = Math.floor(ns_seconds/60);
var seconds = Math.floor(ns_seconds%60);
if (seconds<10) {
seconds = “0”+seconds;
}
time_txt.text = minutes+":"+seconds;
}/
var scrubInterval;
loader.scrub.onPress = function() {
vFrame.onEnterFrame = scrubit;
this.startDrag(false, 0, this._y, 208, this._y);
};
loader.scrub.onRelease = loader.scrub.onReleaseOutside=function () {
vFrame.onEnterFrame = videoStatus;
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("::::: YP Videos :::::", 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(“© 2008 Beta by vSplash”, 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”);
}
};
var vlist:XML = new XML();
vlist.ignoreWhite = true;
vlist.onLoad = function() {
var videos:Array = this.firstChild.childNodes;
for (i=0; i<videos.length; i++) {
videoList.addItem(videos.attributes.desc, videos*.attributes.url);
}
ns.play(videoList.getItemAt(0).data);
videoList.selectedIndex = 0;
};
//new added
var vlist:XML = new XML();
vlist.ignoreWhite = true;
var listClips:Array = new Array;
//listClips is going to be an array that we’re going to use to store a
//reference for each video entry in our list. We’re going to use this
//array to keep the proper video highlighed based on which one is playing.
var whoIsOn:Number = 0;
//whoIsOn is going to keep track of which index number video is playing at any time
var yBegin:Number = videoList._y;
//yBegin is going to be the zero point in the scrolling of the list of video entries,
//and it’s going to be used in a number of calcuations, so we’re going to define it
//as a variable, and it basically equals the starting y coordinate of our videoList object.
vlist.onLoad = function() {
var videos:Array = this.firstChild.childNodes;
for(i=0;i<videos.length;i++) {
videoList.addItem(videos*.attributes.desc,videos*.attributes.url);
}
ns.play(videoList.getItemAt(0).data);
videoList.selectedIndex = 0;
}
//var vidList:Object = new Object();//delete
//vidList.change = function() {//delete
//ns.play(videoList.getItemAt(videoList.selectedIndex).data);//delete
//};//delete
//videoList.addEventListener(“change”, vidList);//delete
vlist.load(“videos.xml”);
//videoList.setStyle(“selectionColor”, 0xCCCCCC);//delete
//videoList.setStyle(“textSelectedColor”, 0x000000);//delete
//videoList.setStyle(“rollOverColor”, 0xCCCCCC);//delete
//**************************
//Now to parse out all the extra information we put into our XML document,
//we start out the same way we did before:
vlist.onLoad = function() {
var videos:Array = this.firstChild.childNodes;
for(i=0;i<videos.length;i++) {
var a = videoList.attachMovie(“listEntry”, “listEntry”+i, videoList.getNextHighestDepth());
listClips.push(a);
a._y = a._heighti;
a._alpha = 66;
loadMovie(videos.attributes.thumb, a.tHolder);
a.vName.text = videos*.attributes.name;
a.vDesc.text = videos*.attributes.desc;
a.numb = i;
a.urlLink = videos*.attributes.url
a.yLoc = (yBegin + (mask._height/2)) - (a._y + (a._height/2));
a.onRelease = function() {
getNewVid(this)
}
a.onRollOver = function() {
if (this.numb <> whoIsOn) {
this._alpha = 100;
this.accent._alpha = 0;
this.back._alpha = 100;
}
}
a.onRollOut = a.onReleaseOutside = function() {
if (this.numb <> whoIsOn) {
this._alpha = 66;
this.accent._alpha = 0;
this.back._alpha = 100;
}
}
a.onRelease = function() {
if (this.numb <> whoIsOn) {
getNewVid(this);
}
}
}
yEnd = yBegin - videoList._height + mask._height + 5;
getNewVid(listClips[whoIsOn]);
}
//Ends Here
//To make the playlist scroll----Starts Here
videoList.onRollOver = scrollPanel;
function panelOver() {
speed = 10;
this.onEnterFrame = scrollPanel;
delete this.onRollOver;
}
var b = mask.getBounds(_root);
function scrollPanel() {
if (_xmouse<b.xMin||_xmouse>b.xMax||_ymouse<b.yMin||_ymouse>b.yMax) {
this.onRollOver = panelOver;
delete this.onEnterFrame;
}
var yDist = _ymouse - 630;
videoList._y += -yDist/speed;
if (videoList._y >= yBegin) {
videoList._y = yBegin;
}
if (videoList._y <= yEnd) {
videoList._y = yEnd;
}
}
//To make the playlist scroll----Ends Here
function getNewVid(who) {
ns.play(who.urlLink);
whoIsOn = who.numb;
//scrolling will not go beyond the limits we set
z = who.yLoc;
if (z >= yBegin) {
z = yBegin;
}
if (z <= yEnd) {
z = yEnd;
}
easeList(z);
//To keep selected the current Video playing
for (i=0; i<listClips.length; i++) {
if ( listClips*.numb == whoIsOn ) {
listClips*._alpha = 100;//adjusting this size will make thumbnail look hazy
listClips*.frame._alpha = 5;//alpha of the selected video
listClips*.back._alpha = 0;
listClips*.accent._alpha = 0;
}else {
listClips*._alpha = 66;
listClips*.frame._alpha = 0;
listClips*.back._alpha = 100;
listClips*.accent._alpha = 0;
}
}
}
//write the easeList function to move the list
function easeList(where) {
delete videoList.onRollOver;
delete videoList.onEnterFrame;
//This controls the speed, so if you want it to move faster decrease this number,
//slower, increase it
videoList.onEnterFrame = function() {
yDist = (videoList._y - where)/7;
videoList._y-=yDist;
if ((videoList._y < (where+2)) && (videoList._y > (where-2))) {
delete videoList.onEnterFrame;
videoList.onRollOver = panelOver;
}
}
}
if(info.code == “NetStream.Play.Stop”) {
v = whoIsOn+1
if (v >= listClips.length ) {
v = 0;
}
getNewVid(listClips[v]);
}
//If you only want to pause the video on start*********************
//Paused Video at Start—actionscript starts here
var firstPlay:Boolean = true;
ns.onStatus = function(info) {
if (info.code == “NetStream.Buffer.Full”) {
bufferClip._visible = false;
if (firstPlay) {
ns.pause();
firstPlay = false;
}
}
if (info.code == “NetStream.Buffer.Empty”) {
bufferClip._visible = true;
}
if (info.code == “NetStream.Play.Stop”) {
ns.seek(0);
ns.pause(); //jump the FLV back to the beginning, and then immediatly pause the video
}
};
//Paused Video at Start—actionscript ends here
//******************************************************/
/*
//If you want to Play the Next Video automatically
//actionscript for this starts here
var firstPlay:Boolean = true;
ns.onStatus = function(info) {
if(info.code == “NetStream.Buffer.Full”) {
bufferClip._visible = false;
}
if(info.code == “NetStream.Buffer.Empty”) {
bufferClip._visible = true;
}
if(info.code == “NetStream.Play.Stop”) {
var t = videoList.selectedIndex + 1;
if (t < videoList.length) {
ns.play(videoList.getItemAt(t).data);
videoList.selectedIndex = t;
}
}
}
//actionscript for this ends here
*/
var t = videoList.selectedIndex + 1;
if (t < videoList.length) {
ns.play(videoList.getItemAt(t).data);
videoList.selectedIndex = t;
}
function (t){
var t = videoList.selectedIndex + 1;
if (t < videoList.length) {
ns.play(videoList.getItemAt(t).data);
videoList.selectedIndex = t;
}
}
================================
Thanks
Kallol[/COLOR]