FLV issues

Ok, I am really struggling. I purchased a video player from flashden, as I am still rather new to actionscripting. I managed to do many large mods to the file to suit my needs but I am struggling with one.

I want to add short commercials before a video.
That would be the content path of adURL in the XML. The normal video content path is videoURL.

XML:


<video>
<video videoURL="Welcome.flv" imageURL="image1.jpg" thumbImage="1.jpg" title="blah" description="Welcome" longdesc="blah blah InVideoURL="test.jpg" adURL="adtest.flv" />
<video videoURL="test.flv" imageURL="image1.jpg" thumbImage="1.jpg" title="blah" description="Welcome" longdesc="blah blah" InVideoURL="" adURL="" />
</video>

Here is the important code of the player (I removed all the items that do not relate to my issue to make it easier):



//Set stage settings
Stage.scaleMode = "noScale";
Stage.displayState = "normal";
Stage.align = "TL";
//EnterFrame
this.onEnterFrame = function() {
	reposition();
	if (showPlaylist && Stage.displayState == "normal") {
		playlist._visible = true;
	} else {
		playlist._visible = false;
	}
	if (vp.playing) {
		isPlaying = true;
	} else {
		isPlaying = false;
	}
	if (isPlaying) {
		//tween out the image
		image.alphaTo = 0;
	}
	if (!isPlaying && vp.playheadTime == 0) {
		//tween in the image
		image.alphaTo = 100;
	}
	image._alpha += (image.alphaTo-image._alpha)/6;
	//trackbar     
	controlbar.trackbar.track_progress._width = vp.playheadPercentage/100*trackWidth;
	controlbar.trackbar.track_buffer._width = vp.bytesLoaded/vp.bytesTotal*trackWidth;
	if (vp.bytesLoaded == vp.bytesTotal) {
		controlbar.trackbar.bufferbars._visible = false;
	} else {
		controlbar.trackbar.bufferbars._visible = true;
	}
	if (scrubbing) {
		controlbar.trackbar.track_progress._width = controlbar.trackbar.track_slider._x;
	} else {
		controlbar.trackbar.track_slider._x = controlbar.trackbar.track_progress._width;
	}
	//volume
	if (volumedragging) {
		vp.volume = (controlbar.volumecontrol.volumeslider._x-controlbar.volumecontrol.volumemask._x)/controlbar.volumecontrol.volumemask._width*100;
	}
	if (controlbar.mutebutton.DoMuteButton._visible) {
		controlbar.volumecontrol.volumefill._width = vp.volume/100*controlbar.volumecontrol.volumemask._width;
	} else {
		controlbar.volumecontrol.volumefill._width = oldVolume/100*controlbar.volumecontrol.volumemask._width;
	}
	//timefield
	minutesPlayed = String(Math.floor(vp.playheadTime/60));
	secondsPlayed = String(Math.round(vp.playheadTime%60));
	minutesTotal = String(Math.floor(vp.totalTime/60));
	secondsTotal = String(Math.round(vp.totalTime%60));
	//add a zero
	minutesPlayed = addZero(minutesPlayed);
	secondsPlayed = addZero(secondsPlayed);
	minutesTotal = addZero(minutesTotal);
	secondsTotal = addZero(secondsTotal);
	//output text
	controlbar.trackbar.track_time.track_time.text = minutesPlayed+":"+secondsPlayed+" / "+minutesTotal+":"+secondsTotal;
	if (Stage.displayState == "normal" && vp._width != playerWidth) {
		vp._x = (playerWidth-vp._width)/2;
		vp._y = (playerHeight-vp._height)/2;
	}
	//scroll playlist 
	if(playlist._xmouse > 0 && playlist._xmouse < playlistWidth && playlist._ymouse > 0 && playlist._ymouse < playlistHeight){
		if (playlistHeight != undefined) {
			thumbrowYgoto -= (playlist._ymouse-(playlistHeight/2))/playlistHeight*0.5*100;
		}
		if(thumbrowYgoto >0){
			thumbrowYgoto = 0;
		}
		if(thumbrowYgoto <  - (playlist.list._height - playlistHeight)-10){
			thumbrowYgoto =  - (playlist.list._height - playlistHeight)-10;
		}
		
	}
	playlist.list._y += (thumbrowYgoto - playlist.list._y) * 0.2;
	
	if(Stage.displayState == "fullScreen"){
		controlbar.OriginalSizeButton.enabled = false;
		controlbar.OriginalSizeButton.visible = false;
	}
	
	if (Stage.displayState == "normal") {
			vp._width = playerWidth;
			vp._height = playerHeight;
			//reposition
			vp._x = 0;
			vp._y = 0;
	} else {
		
		//set player size
			vp._width = Stage.width;
			vp._height = Stage.height-controlbar.control_bg._height;
			//reposition
			vp._x = -_x;
			vp._y = -_y;
		
	}
};
//
function addZero(num) {
	//adds a zero to single digit number
	if (length(num)<2) {
		num = "0"+num;
	}
	return num;
}

//
function loadVideo(num) {
	
	currentVideo = num;
	image.imageHolder.loadMovie(allVideos[num]["imageURL"]);
	_parent.extra_info.track_title.text = allVideos[num]["title"];
	_parent.extra_info.description_text.text = allVideos[num]["description"];
	_parent.extra_info.long_desc.text = allVideos[num]["longdesc"];
	_parent.extra_info.thumb.loadMovie(allVideos[num]["thumbImage"]);
	InVideo.InVideoLoader.loadMovie(allVideos[num]["InVideoURL"]);

		vp.contentPath = allVideos[num]["videoURL"];
		vp.seek(0);
	
	
	
}

Stage.addListener(listener);
vp.complete = function() {
	
	if (autoPlay == true) {
		currentVideo += 1;
		if (currentVideo>=allVideos.length) {
			currentVideo = 0;
		}
		loadVideo(currentVideo);
		
		vp.play();
	} else {
		vp.stop();
	}
};
//Buttons
image.bigButton.onPress = function() {
	
	vp.play();

};



controlbar.PreviousButton.onPress = function() {
	currentVideo -= 1;
	if (currentVideo<0) {
		currentVideo = allVideos.length-1;
	}
	loadVideo(currentVideo);
};
controlbar.NextButton.onPress = function() {
	currentVideo += 1;
	if (currentVideo>=allVideos.length) {
		currentVideo = 0;
	}
	loadVideo(currentVideo);
};



I thought I could just change the content path in the loadVideo function to the adURL and then in the vp.complete function redirect the video to play again but change the content path to the actual video content path (videoURL). I’m either wrong or executed it wrong when I tried it.

If anybody has any ideas, could you share? I just can’t get this to work. ahh! :be: