Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-13-2008, 10:58 PM   #1
agneturge
Registered User
 
Join Date: Sep 2008
Posts: 2
Red face Video player help

I have video player that uses elements of the FLVPlayback component and some custom classes...one of which is a configuration manager (that I friend gave me) which makes it easier to load XML without having to go through the whole childNode.childNode complications.

Anyway....everything it XML driven...the video, subtitles (which are generated via cuepoints), video titles and the video list (which are essentially buttons for each video). Right now, what happens is the application runs, all the video titles are listed, and the first video on the list plays....when it ends, the playback stops, loads a screen similar to YouTube where you can choose to replay the recent video or play the next title which is named along with a description. These last two items are also XML driven but what happens is they show the info for the LAST video in the series rather than the next video. And it doesn't matter which video you select..choose the 4th video, it will always show the next video to be the last...choose the last...it will show the same.

I have a function called init that creates the containers, populates the video titles and tell those titles to play in the player when clicked.

Code:
function init ():Void
{
	var x = 0;
	var y = 0;
	var offset = 0;
	var initialX = 4;
	var initialY = 4;
	var offsetX = 2;
	var offsetY = 47;
	var currentX = initialX;


	
///this loop connects left nav buttons to corisponding videos
	for (i = 0; i < pods.length; i++)
	{
		if (i != 0 && i % 1 == 0)
		{
			initialY += offsetY;
			currentX = initialX;
		}
		
		var container = this.createEmptyMovieClip ("container" + i, this.getNextHighestDepth ());
		containerArray.push(container);
		container.attachMovie ("playListItem","newListItem",container.getNextHighestDepth (),{_x:currentX, _y:initialY});
		container.id=i; 
		container.cuePointXML = myConfig.xml.videos.video[i].cuePointXML;
		container.newListItem.body = myConfig.xml.videos.video[i].desc;
		cover.vidNext.vSum = myConfig.xml.videos.video[i].vSum; 
		cover.vidNext.vidTitle = myConfig.xml.videos.video[i].desc;

		if (i == currentVid)
		{
			container.newListItem.gotoAndStop("_sel");
					trace(cover.vidNext.vSum);
		}

	//container interactivity	
		container.onRelease = function ()
		{
			for (var i=0; i<containerArray.length; i++){
				containerArray[i].newListItem.gotoAndStop("_deSel");
			}	

			cover._visible=false; // replay-next video screen
			this.newListItem.gotoAndStop("_sel");
			//trace(_root["container" + selBtn]);
			selBtn = this.id;
			currentVid=selBtn;		
			//my_FLVPlybk.stop();
			my_FLVPlybk.contentPath = null;
			cuePointLoader.load(this.cuePointXML);
		};
	}
	
	trace("Loading cuePointXML for first video");
	cuePointLoader.load(myConfig.xml.videos.video[currentVid].cuePointXML);
}
pulling this code out causes keeps text from populating:
Code:
	

cover.vidNext.vSum = myConfig.xml.videos.video[i].vSum; 
cover.vidNext.vidTitle = myConfig.xml.videos.video[i].desc;
..so I've tried placing it in other locations but not getting favorable results.

Anyway, any suggestions would be helpful. I'll post all the code in a response.
agneturge is offline   Reply With Quote
Old 09-13-2008, 11:05 PM   #2
agneturge
Registered User
 
Join Date: Sep 2008
Posts: 2
Default And here's the code

Code:
import mx.utils.Delegate;
import com.jor.utils.Timer;
import com.jor.events.TimerEvent;
import com.moxieinteractive.application.ConfigurationManager;
import com.moxieinteractive.tracking.hbx.HBX;
import gs.TweenLite;
import gs.easing.*
import mx.video.*;

subMC._visible=false;
cover._visible=false;
subtitles_txt.text = '';

var containerArray:Array = new Array();

var myConfig:ConfigurationManager = new ConfigurationManager ();
myConfig.addEventListener (ConfigurationManager.EVENT_CONFIG_LOADED,HandleConfigLoad);


var cuePointLoader:ConfigurationManager = new ConfigurationManager();
cuePointLoader.addEventListener(ConfigurationManager.EVENT_CONFIG_LOADED, handleCuePointLoad);
var currentCuePoints:Array;
var currentSubtitles:Object;


var pods:Array = new Array();
var vWidth = 576;
var vHeight = 324;
var currentVid:Number = 0;
//var nextVid:String = currentVid++;
ConfigurationManager.debug= true;


///retractable controls
movieNav._y = highP;

var myTimer:Timer = new Timer(3000, 1);
myTimer.addEventListener(TimerEvent.TIMER, Delegate.create(this, retractor));
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, Delegate.create(this, retractor));
myTimer.start();



var highP = 290;
var lowP = 325;
var contracted:Boolean = true;


function retractor(event:TimerEvent):Void {
	TweenLite.to(movieNav, .75, {_y:lowP});
	contracted = true;
}


onEnterFrame = function(){
	if(contracted)
	{
		if(_ymouse > 260)
		{
			TweenLite.to(movieNav, .75, {_y:highP});
			contracted = false;
		}
		else
		{
		}
	}
	else
	{
		if(_ymouse > 260)
		{
			myTimer.stop();
		}
		else
		{
			contracted = true;
			myTimer.delay = 1500;
			myTimer.reset();
			myTimer.start();
		}
	}
}
/////////////////

///loading xml
/// evaluating attributes in xml document.
function HandleConfigLoad (e:Object) 
{
	for(var i=0; i < myConfig.xml.videos.video.length; i++)
	{		var vlist:Object = myConfig.xml.videos.video[i];	
		var video = new Object ();
		
		video.url = vlist.url;
		video.desc = vlist.desc;
		video.cuePointXML = vlist.cuePointXML;

		pods.push (video);
	}
	init ();
}


function handleCuePointLoad(e:Object):Void
{
	
	// play the video
	my_FLVPlybk.contentPath = myConfig.xml.videos.video[currentVid].url;
	my_FLVPlybk.width = vWidth;
	my_FLVPlybk.height = vHeight;
	
	// add cue points for new video
	addXMLCuePoints();

}


function removeXMLCuePoints():Void
{
	//remove any current as cue points in the FLVPlayback component
	for(var i = 0; i < currentCuePoints.length;  i++)
	{
		//trace("** removing cuePoint **");
		my_FLVPlybk.removeASCuePoint(currentCuePoints[i]);
	}
}


function addXMLCuePoints():Void
{
		// reset temporary storage and add cue point for current video to FLVPlayback
	currentCuePoints = new Array();
	currentSubtitles = new Object();
	
	for(var i = 0; i < cuePointLoader.xml.cuepoints.cuepoint.length; i++)
	{
		var cueName = cuePointLoader.xml.cuepoints.cuepoint[i].name;
		var cueTime = cuePointLoader.xml.cuepoints.cuepoint[i].time;
		var cueData = cuePointLoader.xml.cuepoints.cuepoint[i]._value;
		
		var cueObj:Object = new Object();
		cueObj.name = cueName;
		cueObj.time = Number(cueTime);
		cueObj.type = "actionscript";
		
		currentCuePoints.push(cueObj);
		
		currentSubtitles[cueName] = cueData;
		
		my_FLVPlybk.addASCuePoint(cueObj);
				
		//trace("** added cuePoint name: " + cueObj.name + " | time: " + cueObj.time);
		//trace("cuePoint data: " + currentSubtitles[cueObj.name]);
	}

}


myConfig.load ("xml/playlist.xml"); 

///create containers
function init ():Void
{
	var x = 0;
	var y = 0;
	var offset = 0;
	var initialX = 4; // inital x position of first container
	var initialY = 4; // inital y position of first container
	var offsetX = 2;  // x space between containers - not used for this 
	var offsetY = 47; // y space between containers
	var currentX = initialX;


	
///this loop connects left nav buttons to corisponding videos
	for (i = 0; i < pods.length; i++)
	{
		if (i != 0 && i % 1 == 0)
		{
			initialY += offsetY;
			currentX = initialX;
		}
		
		var container = this.createEmptyMovieClip ("container" + i, this.getNextHighestDepth ());
		containerArray.push(container);//adding each container to the array
		container.attachMovie ("playListItem","newListItem",container.getNextHighestDepth (),{_x:currentX, _y:initialY});
		container.id=i; ///this. if referenceing the outside loop.
		container.cuePointXML = myConfig.xml.videos.video[i].cuePointXML;
		container.newListItem.body = myConfig.xml.videos.video[i].desc;		// dynamic title in button
		cover.vidNext.vSum = myConfig.xml.videos.video[i].vSum; 			//dynamic video summary cover
		cover.vidNext.vidTitle = myConfig.xml.videos.video[i].desc; 		// dynamic video title on cover

		if (i == currentVid)
		{
			container.newListItem.gotoAndStop("_sel");
					trace(cover.vidNext.vSum);
		}

	//container interactivity	
		container.onRelease = function ()
		{
			for (var i=0; i<containerArray.length; i++){
				containerArray[i].newListItem.gotoAndStop("_deSel");
			}	

			cover._visible=false;											// replay-next video screen
			this.newListItem.gotoAndStop("_sel");
			//trace(_root["container" + selBtn]);
			selBtn = this.id;
			currentVid=selBtn;		
			//my_FLVPlybk.stop();
			my_FLVPlybk.contentPath = null;
			cuePointLoader.load(this.cuePointXML);
}



var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void 
{
    //trace("video complete: " + currentVid + " : " + myConfig.xml.videos.video.length);
	
	
	subtitles_txt.text = '';

	for (var i=0; i<containerArray.length; i++)
	{
		containerArray[i].newListItem.gotoAndStop("_deSel");
	}
	
	if(currentVid == (myConfig.xml.videos.video.length - 1))
	{
		currentVid = 0;
	}
		
	else
	{
		++currentVid;
		trace("currentVid: " + currentVid);
		
		my_FLVPlybk.contentPath = null;
		cover._visible=true;
		my_FLVPlybk.stop();// stop video when complete

		my_FLVPlybk.width = vWidth;
		my_FLVPlybk.height = vHeight;
	}
	
	containerArray[currentVid].newListItem.gotoAndStop("_sel");
	selBtn = currentVid;
};

listenerObject.cuePoint = function(eventObject:Object):Void 
{
name: " + eventObject.info.name + " | time: " + eventObject.info.time + " | type: " + eventObject.info.type); 
	movieNav.subtitleMove.subMC.subtitles_txt.text = currentSubtitles[eventObject.info.name];
};


///////////////////////////////video controls////////////////////////////////
my_FLVPlybk.backButton = movieNav.my_bkbttn;
my_FLVPlybk.forwardButton = movieNav.my_fwdbttn;
my_FLVPlybk.playPauseButton = movieNav.my_plypausbttn;
my_FLVPlybk.stopButton = movieNav.my_stopbttn;
my_FLVPlybk.seekBar = movieNav.my_seekBar;
my_FLVPlybk.muteButton = movieNav.myMute;
my_FLVPlybk.volumeBar = movieNav.my_volumeBar;
my_FLVPlybk.addEventListener("complete", listenerObject);
my_FLVPlybk.addEventListener("cuePoint", listenerObject);

//////////////////////////////////////////////////////////////////////////////


///video cover - displays after video is finished
cover.vidReplay.onRelease = function()
{
	trace("replay clicked");
	cover._visible=false;	/// replay/next screen
	
};


cover.vidNext.onRelease = function()
{
	trace("next clicked");
        cover._visible=false;	
};
agneturge is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MP3 Player vs. Video Player nickchrisless ActionScript 2.0 4 10-05-2007 06:36 PM
Trouble with video player ndisdabest ActionScript 2.0 2 09-25-2007 06:53 PM
[AS2] Video Player Class w/ NetStream Video Object tsj4 Components 3 09-17-2007 08:11 PM
Flash 6 (or 7 video) player hogs the bandwidth. : ( OM2 Other Flash General Questions 0 09-02-2007 11:28 PM
Some Flash Video Converter Tools Compare terry117 Detention 7 05-18-2006 02:08 AM


All times are GMT. The time now is 12:33 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.