# FLV Playlist

**URL:** https://forum.kirupa.com/t/flv-playlist/256243
**Category:** Uncategorized
**Created:** [April 1, 2008, 6:33am UTC](https://forum.kirupa.com/t/flv-playlist/256243 "2008-04-01T06:33:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kallol\_kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kallol_kirupa/32/18661_2.png) [@kallol\_kirupa](https://forum.kirupa.com/u/kallol_kirupa)
#### Post date: [April 1, 2008, 6:33am UTC](https://forum.kirupa.com/t/flv-playlist/256243/1 "2008-04-01T06:33:33Z")

</div>

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](https://ns.play)(videoList.getItemAt(t).data);  
[//videoList.selectedIndex](https://videoList.selectedIndex) = t;  
//}  
}  
}  
playButton.onRelease = function() {  
ns.pause();  
};  
rewindButton.onRelease = function() {  
ns.seek(0);  
};  
forward.onRelease=function(t){  
[//ns.seek](https://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 = amountLoaded_208.9;  
loader.scrub.\_x = ns.time/duration_208.9;  
//trace (duration);  
//trace (amountLoaded);  
//trace (ns.time);  
[//timePlayed=Math.round](https://timePlayed=Math.round) (ns.time);  
seconds=Math.floor(ns.time%60);  
//playSec=seconds;  
minute=Math.floor(ns.time/60);  
[//duration=Math.floor](https://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](https://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](https://vidList.change) = function() {//delete  
[//ns.play](https://ns.play)(videoList.getItemAt(videoList.selectedIndex).data);//delete  
//};//delete  
[//videoList.addEventListener](https://videoList.addEventListener)(“change”, vidList);//delete  
vlist.load(“videos.xml”);  
[//videoList.setStyle](https://videoList.setStyle)(“selectionColor”, 0xCCCCCC);//delete  
[//videoList.setStyle](https://videoList.setStyle)(“textSelectedColor”, 0x000000);//delete  
[//videoList.setStyle](https://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.\_height_i;  
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 &lt;&gt; whoIsOn) {
            this._alpha = 100;
            this.accent._alpha = 0;
            this.back._alpha = 100;
         }
      }
      a.onRollOut = a.onReleaseOutside = function() {
         if (this.numb &lt;&gt; whoIsOn) {
            this._alpha = 66;
            this.accent._alpha = 0;
            this.back._alpha = 100;
         }
      }
      a.onRelease = function() {
         if (this.numb &lt;&gt; 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]
