FLV Player Actionscript problems

This is a discussion on "FLV Player Actionscript problems" within the Flash & Multimedia Forum section. This forum, and the thread "FLV Player Actionscript problems are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 29th, 2007, 22:19
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

  #2 (permalink)  
Old May 1st, 2007, 20:00
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: FLV Player Actionscript problems

I don't have a lot of time to write something out right now...(busy at work) but have you tried using the .attachvideo attribute to attach it to an empty movieclip?

Here is a link to a great resource that might help you...

http://www.quip.net/blog/2006/flash/...external-video

...then instead of just putting the path of the video, instead use a variable that can be filled when the user selects which video they want from the list. The list sends set the variable to the flv name and passes it to the player.

Hope this helps,

Scott
Last Blog Entry: Yay!? (Oct 8th, 2007)
Reply With Quote
  #3 (permalink)  
Old May 2nd, 2007, 00:44
New Member
Join Date: Apr 2007
Location: Bloomington
Age: 26
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: FLV Player Actionscript problems

Thanks for the response.

I had seen a bunch of tutorials about making everything from scratch, but in the end decided to go with the FLV player component despite all it's deficencies. I really needed to be able to control play state and scrubber state.

As it turns out, I was able to fix the problem. I think my problem, as usual, may have been when the component was loading so if I were to change the first code statement I had above to:

Code: Select all
movie.onLoad = function() {
            move.contentPath = _root.data_mc.currentPath;
            setupMovie(); //setup the movie player
            movie.play(); //autoplay the movie            
}


It worked.

I don't know if that will be useful to anyone on the forum (perhaps my problem is so specific), but here's how I solved this.

Thanks,

Will
Reply With Quote
Reply

Tags
actionscript, component, flv

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with Forms in ActionScript 3.0 dgstarr Flash & Multimedia Forum 3 Sep 7th, 2007 20:37
Radio Button Problems in ActionScript 3.0 dgstarr Flash & Multimedia Forum 1 Sep 6th, 2007 17:11
Problems with Volume Control for Flash MP3 Player Phil Flash & Multimedia Forum 3 Aug 16th, 2007 09:39
Actionscript 3.0 Sgaspar11 Flash & Multimedia Forum 7 May 28th, 2007 18:31
Embeded Mp3 player problems Zaine7673 Web Page Design 2 Dec 17th, 2006 13:29


All times are GMT. The time now is 22:34.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43