View Single Post
  #1 (permalink)  
Old Apr 29th, 2007, 22:19
kalli21 kalli21 is offline
New Member
Join Date: Apr 2007
Location: Bloomington
Age: 26
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
FLV Player Actionscript problems

I have been having a problem with using the video player components in Flash. I do not have a great deal of experience
with this technology so it could just be something that I'm not seeing. I could really use some help and would greatly
appreciate it.

So what my basic setup is that I have a movie selector device on a different frame on the same movie clip (showing
thumbnails for instance, the user pick the movie and it takes them to this page). The movie selector stores the path
name for the movie selected in an actionscript variable in another movie clip. I'm not having any problems accessing
that variable name.

So on this page I basically want a movie player that can take that filename and load the file without user
intervention. Also I need it to be an FLV movie player component rather than the regular video component because I NEED
the FLVPlayback.complete, FLVPlayback.scrubFinish, FLVPlayback.playing, and FLVPlayback.paused events for data
recording purposes. My understanding was that the other video display components couldn't handle this.

Anyways, I currently have the problem that this component makes me load a video into the movie to begin with when I put
it on the stage in the parameter tab of properties, which I don't want to do--because this will change based only on
what they choose in the selector page. Also, the only way I can have the movie that they have choosen play (as opposed
to this one I had to put in the paramaters tab) is to have them click another button (called switch_btn that switches
the movie I don't want to play with the one the user selected).
Here is the code. The first snippet shows my attempt to in the switch_btn.onPress event handler to say if the
switch_btn hasn't already been pressed (that is the switch_btn.select) then load the movie and play it. I want this to
happen basically when the movie loads.

Code: Select all
 
 
//this is for the load movie button
switch_btn.onPress = function() {
 if(!switch_btn.select) { // if the button hasn't already been pressed
  switch_btn.selectButton(true); //change the state to loaded
 
  setupMovie(); //setup the movie player
  movie.load(_root.data_mc.currentPath); //load a new movie (the one for this movie)
  movie.play(); //autoplay the movie
 }
}
The second two snippits are some of the recording features and making a timer for the movie (i.e., current time out of
total time: 1:26 / 3:00 min). Not sure if this is necessary, but I'll include it anyways.

Code: Select all
 
//setup movie listeners
function setupMovie () {
 //timer that updates the movie movie timer
 timer = setInterval(updateTime, 0.25);
 
 //listen for when the scrubber is moved to a different time in the movie
 var listenerObjectScrub:Object = new Object();
 listenerObjectScrub.scrubFinish = function(eventObject:Object):Void {
  inASeek = true; //tell Actionscript that we are in a seek state
 };
 movie.addEventListener("scrubFinish", listenerObjectScrub);
 
 //listen for when a movie begins to play from a paused, seeked or stopped state
 var listenerObjectPlay:Object = new Object();
 listenerObjectPlay.playing = function(eventObject:Object):Void {
 
  // record the information from the scrubber movement
  if(inASeek) { 
   _root.data_mc.movieData.push(movie.playheadTime);
   inASeek = false; // we are no longer in a seek state
  }
  if(inAPause) {
   inAPause = false; //acknowledge the pause but don't record anything
  } else {
   _root.data_mc.movieData[0]++; //record any genuine plays from the beginning of the movie
  }
 };
 movie.addEventListener("playing", listenerObjectPlay);
 
 //listen for any pauses
 var listenerObjectPause:Object = new Object();
 listenerObjectPause.paused = function(eventObject:Object):Void {
  inAPause = true;
 };
 movie.addEventListener("paused", listenerObjectPause);
 
 
 //listen for when the movie reaches the end of the movie
 var listenerObjectComplete:Object = new Object();
 listenerObjectComplete.complete = function(eventObject:Object):Void {
  _root.data_mc.movieData[1]++;
 };
 movie.addEventListener("complete", listenerObjectComplete);
}
// update the timer
function updateTime( ) {
 //get the minutes and seconds of the playhead
 var rawSecs = Math.round(movie.playheadTime);
 
 var min = Math.floor(rawSecs / 60);
 var sec = rawSecs % 60;
 
 //add a leading 0 if minutes or seconds are single digit
 var minText = (min < 10)?"0"+min:min;
 var secText = (sec < 10)?"0"+sec:sec;
 
 //figure out how long the movie is approximately
 var rawSecsT = Math.round(movie.playheadTime / (movie.playheadPercentage / 100));
 
 //record this total length as minutes and seconds before
 var minT = Math.floor(rawSecsT / 60);
 var secT = rawSecsT % 60;
 
 var minTText = (minT < 10)?"0"+minT:minT;
 var secTText = (secT < 10)?"0"+secT:secT;
 
 //update the current time
 current_txt.text = minText + ":" + secText;
 
 // update the total time of the movie
 if(movie.playheadPercentage == 0) total_txt.text = "/ 00:00";
 else total_txt.text = "/ " + minTText + ":" + secTText;
}
Any ideas of how I can make this work the way I want it?

Thanks,
Will
Reply With Quote