troubleshooting Question

How to get the thumbnails working im my XML Driven Video Gallery with Playlist?

Avatar of samuels27921
samuels27921 asked on
XMLAdobe Flash
15 Comments2 Solutions345 ViewsLast Modified:
Hi,
I have put together a XML Driven Video Player with auto thumbnail detection but there is a problem.The Video plays but, The thumbs will not show. I think my thumbnail function is not reaching the correct node in my XML.Can someone take a look at my Actionscript Please? The Action Script is below. The XML is at the bottom of this post. The top half of the code is the video playing code the bottom is for the thumbs.
 
Actionscript 2.0
---------------------------------------------------------------
 
 
var nc:NetConnection = new NetConnection();
nc.connect(null);
 
var ns:NetStream = new NetStream(nc);
 
ns.setNufferTime(30);
 
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.Buffer.Stop") {
ns.seek(0);
}
};
theVideo.attachVideo(ns);
 
rewindButton.onRelease = function() {
ns.seek(0);
};
playButton.onRelease = function() {
ns.pause();
};
 
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded:Number;
var duration:Number;
 
ns["onMetaData"] = function (obj) {
duration = obj.duration;
};
 
function videoStatus() {
amountLoaded = ns.bytesLoaded/ns.bytesTotal;
loader.loadbar._width = amountLoaded*187.4;
loader.scrub._x = ns.time/duration*187.4;
}
 
var scrubInterval;
 
loader.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit, 10);
this.startDrag(false,0,this._y,187.4,this._y);
};
 
loader.scrub.onRelease = loader.scrub.onReleaseOutside=function () {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus, 100);
this.stopDrag();
};
 
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/187)*duration));
}
 
var theMenu:ContextMenu = new ContextMenu();
theMenu.hideBuiltInItems();
_root.menu = theMenu;
 
var i1:ContextMenuItem = new ContextMenuItem(":::::Video Controls:::::", trace);
theMenu.customItems[0] = i1;
 
var i2:ContextMenuItem = new ContextMenuItem("Play / Pause Video", pauseIt, true);
theMenu.customItems[1] = i2;
 
var i3:ContextMenuItem = new ContextMenuItem("Replay Video", replayIt);
theMenu.customItems[2] = i3;
 
var i4:ContextMenuItem = new ContextMenuItem("All Rights Reserved 2009", trace, true);
theMenu.customItems[3] = i4;
 
var i5:ContextMenuItem = new ContextMenuItem("SamAndOnline.com Video Player", trace);
theMenu.customItems[4] = i5;
 
function pauseIt() {
ns.pause();
 
}
 
function replayIt() {
ns.seek(0);
}
 
//sound controls
 
_root.createEmptyMovieClip("vSound",_root.getNextHighestDepth());
vSound.attachAudio(ns);
 
var so:Sound = new Sound(vSound);
 
 
 
 
so.setVolume(100);
volControl.volcon.slider1.onPress = function() {
this.startDrag(true,volControl.volcon.groove1._x,volControl.volcon.groove1._y,vo lControl.volcon.groove1._x,volControl.volcon.groove1._y+100);
slideit = setInterval(volControl.volcon.slider_1Move, 100, this);
};
volControl.volcon.slider1.onRelease = function() {
this.stopDrag();
clearInterval(slideit);
mute.gotoAndStop("on");
};
volControl.volcon.slider1.onReleaseOutside = function() {
this.stopDrag();
clearInterval(slideit);
mute.gotoAndStop("on");
};
 
 
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");
}
};
//listBx
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({label:videos[i].attributes.desc,data:videos[i].attributes.url ,image:videos[i].attributes.thumb});
}
//play 1st video
ns.play(videoList.getItemAt(0).data);
videoList.selectedIndex = 0;
//would like to reference something in the XML File with the thumb attribute
thumbnails_fn(i);
 
};
 
var vidList:Object = new Object();
 
vidList.change = function() {
ns.play(videoList.getItemAt(videoList.selectedIndex).data);
};
videoList.addEventListener("change",vidList);
 
vlist.load("videos.xml");
 
 
soundb.onRelease = function() {
if (volControl.switch2=open2) {
volControl.gotoAndPlay("open");
} else {
volControl.play();
}
};
 
///---------------------------------------------------------
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 10;
tscroller.onEnterFrame = function() {
if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=40) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}
 
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(eval("thumbnail_mc.t"+k)._width+5)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(image[k], "thumbnail_mc.t"+k);
}
trace(videoList.getItemAt(0).image+ "k= "+k+" "+videos.length+" pv "+target_mc.pictureValue+" thumbnails");
 
 
 
 
 
XML Example
------------------------------------------------
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<videos>
<video url="vid1.flv" desc="Video 1" thumb="1.jpg"/>
<video url="vid2.flv" desc="Video 2" thumb="2.jpg"/>
</videos>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros