# Need help with xml loading video player

**URL:** <https://forum.kirupa.com/t/need-help-with-xml-loading-video-player/264958>\
**Category:** flash\
**Created:** [July 2, 2008, 2:46pm UTC](https://forum.kirupa.com/t/need-help-with-xml-loading-video-player/264958 "2008-07-02T14:46:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dowe](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@dowe](https://forum.kirupa.com/u/dowe)\
**Post date:** [July 2, 2008, 2:46pm UTC](https://forum.kirupa.com/t/need-help-with-xml-loading-video-player/264958/1 "2008-07-02T14:46:16Z")

</div>

I have a video player I am using and need help with one of the functions. My video player is xml loaded and does a great job. what i need it to do is move on to the next item in the xml list instead of simply looping the top video in the list over and over again. I not sure if i need some sort of listener to tell it to jump to the next item. i have been playing around with it and am now throwing it up for help. here is the AS

stop();

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);  
}  
}

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

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

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;  
}

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("::::: 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(“©NA”,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++) {  
videoList2.addItem(videos\*.attributes.desc,videos\*.attributes.url);  
}

```
ns.stop(videoList2.getItemAt(0).data);
videoList2.selectedIndex = 0;

```

}

var vidList:Object = new Object();

vidList.change = function() {  
ns.play(videoList2.getItemAt(videoList2.selectedIndex).data);  
}

videoList2.addEventListener(“change”,vidList);

vlist.load(“xml/purchasing\_videos.xml”);

videoList2.setStyle(“selectionColor”,0xCCCCCC);  
videoList2.setStyle(“textSelectedColor”,0x000000);  
videoList2.setStyle(“rollOverColor”,0xCCCCCC);

---

<div class="post-metadata">

**Author:** ![dowe](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@dowe](https://forum.kirupa.com/u/dowe)\
**Post date:** [July 2, 2008, 4:18pm UTC](https://forum.kirupa.com/t/need-help-with-xml-loading-video-player/264958/2 "2008-07-02T16:18:38Z")

</div>

Or maybe just make it stop after the first video plays, anything would be better then it looping.
