Hi Everyone,
I am currently working on FLV player that plays 5 movies continiously. It player the array off videos great, i am running into a problem with my button codes. For example if a viewer is watching video 3 and clicks back to video 1, the next flv that plays is 4 not 2. It just keeps running through the loop.
my actionsript is as follows:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
my_FLVPlybk.attachVideo(ns);
ns.setBufferTime(10);
var videoList:Array = new Array();
videoList[0] = "video1.flv";
videoList[1] = "video2.flv";
videoList[2] = "video3.flv";
videoList[4] = "video4.flv";
videoList[5] = "video5.flv";
var currentlyPlaying:Number = 0;
// Initialize first play
my_FLVPlybk.contentPath = videoList[currentlyPlaying]; // Changed this as it is a specific function for changing the file
my_FLVPlybk.play(); // Should start the player without the parameters from the component
trace(currentlyPlaying);
var listenerObject:Object = new Object(); // create listener object
listenerObject.complete = function(eventObject:Object):Void {
currentlyPlaying++;
if (currentlyPlaying >= videoList.length) { // Resets counter if reaches end of array
currentlyPlaying = 0;
}
trace(currentlyPlaying); // Just traces new file in testing
my_FLVPlybk.contentPath = videoList[currentlyPlaying]; // Change source file
my_FLVPlybk.play(); // Play new file
_root.test.gotoAndStop(2);
};
my_FLVPlybk.addEventListener("complete", listenerObject); // Initialize listener
import mx.video.*;
my_FLVPlybk.bufferingBar = my_buffrgbar;
my_FLVPlybk.bufferingBarHidesAndDisablesOthers = true;
my_FLVPlybk.autoPlay = true;
my_FLVPlybk.playheadTime;
my_FLVPlybk.totalTime;
my_FLVPlybk.playPauseButton = playpausebtn;
my_FLVPlybk.seekBar = myseekBar;
my_FLVPlybk.volumeBar = volumeB;
my_FLVPlybk.volume = 100;
//////////////////////
///////////////////// time functionality
var listenerObjectBuff:Object = new Object();
var listenerObjectPlay:Object = new Object();
listenerObjectPlay.playheadUpdate = function(eventObjectPlay:Object):Void {
var elapsedTime = eventObjectPlay.playheadTime;
var minutes:Number = Math.floor(elapsedTime/60);
var seconds:Number = Math.floor(elapsedTime%60);
var elapsedTime_str:String = ((minutes>=10) ? minutes : "0"+minutes)+":"+((seconds>=10) ? seconds : "0"+seconds);
txTime2.text = elapsedTime_str;
//
/////// convert miliseconds to seconds and minutes
var minutes2:Number = Math.floor((my_FLVPlybk.totalTime)/60);
var seconds2:Number = Math.floor((my_FLVPlybk.totalTime)%60);
if (minutes2<0) {
minutes2 = 0;
}
if (seconds2<0) {
seconds2 = 0;
}
var remainingTime_str:String = ((minutes2>=10) ? minutes2 : "0"+minutes2)+":"+((seconds2>=10) ? seconds2 : "0"+seconds2);
txTime1.text = remainingTime_str;
};
//////////// eventlistener to listen to play head
my_FLVPlybk.addEventListener("stateChange", listenerObjectBuff);
my_FLVPlybk.addEventListener("playheadUpdate", listenerObjectPlay);
/////////////////////////////////////////////////////
onEnterFrame = function () {
if (my_FLVPlybk.playheadTime == 0.0) {
_root.curtain._alpha = 100;
}
};
My button code is as follows:
b1.onRelease = function():Void
{
my_FLVPlybk.stop();
my_FLVPlybk.contentPath = videoList[0];
my_FLVPlybk.play();
}
b2.onRelease = function():Void
{
my_FLVPlybk.stop();
my_FLVPlybk.contentPath = videoList[1];
my_FLVPlybk.play();
}
b3.onRelease = function():Void
{
my_FLVPlybk.stop();
my_FLVPlybk.contentPath = videoList[2];
my_FLVPlybk.play();
}
b4.onRelease = function():Void
{
my_FLVPlybk.stop();
my_FLVPlybk.contentPath = videoList[3];
my_FLVPlybk.play();
}
b5.onRelease = function():Void
{
my_FLVPlybk.stop();
my_FLVPlybk.contentPath = videoList[4];
my_FLVPlybk.play();
}
b6.onRelease = function():Void
{
my_FLVPlybk.stop();
my_FLVPlybk.contentPath = videoList[5];
my_FLVPlybk.play();
}
Thank you so much!!! i would really really appreciate the help. :tini: