creating custom flash buffer

  • kfc06
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 28, 2009
  • Posts: 12
  • Status: Offline

Post July 28th, 2009, 4:40 am

I have found this on the net and been trying to get this to work but its not happening, anyone any ideas why?

Code: [ Select ]
 
import fl.video.*;
import fl.controls.ProgressBarMode;
import fl.transitions.*;
import fl.transitions.easing.*;
// Set Variables
 
var flvControl = display;
var flvSource = "mymovie.mov";
 
display.bufferTime = 30;
 
 
//fade the mcBufferingIndicator when buffered.
function onPlayerBuffered(event:VideoEvent)
{
 
TransitionManager.start(mcBufferingIndicator, {type:Fade, direction:Transition.OUT, duration:0.5, easing:Strong.easeOut});
}
 
display.addEventListener(VideoEvent.PLAYING_STATE_ ENTERED, onPlayerBuffered);
 
//Display the mcBufferingIndicator when buffering.
function onPlayerNotBuffered(event:VideoEvent)
{
mcBufferingIndicator.visible = true;
}
display.addEventListener(VideoEvent.BUFFERING_STAT E_ENTERED, onPlayerNotBuffered);
 
// Create event handler functions to control the progressbar
function progressHandler(event:VideoProgressEvent):void
{
var bl = Math.round(event.bytesLoaded/1000);
var bt = Math.round(event.bytesTotal/1000);
 
// Update progress...
pb.setProgress(bl,bt);
}
 
function readyHandler(event:VideoEvent):void
{
// Remove progressbar when we start playing...
removeChild(pb);
}
 
// Set progress bar state
pb.mode = ProgressBarMode.MANUAL;
pb.indeterminate = false;
 
// Add listeners and load the video
flvControl.addEventListener(VideoProgressEvent.PRO GRESS, progressHandler);
flvControl.addEventListener(VideoEvent.READY, readyHandler);
flvControl.source = flvSource;
 
  1.  
  2. import fl.video.*;
  3. import fl.controls.ProgressBarMode;
  4. import fl.transitions.*;
  5. import fl.transitions.easing.*;
  6. // Set Variables
  7.  
  8. var flvControl = display;
  9. var flvSource = "mymovie.mov";
  10.  
  11. display.bufferTime = 30;
  12.  
  13.  
  14. //fade the mcBufferingIndicator when buffered.
  15. function onPlayerBuffered(event:VideoEvent)
  16. {
  17.  
  18. TransitionManager.start(mcBufferingIndicator, {type:Fade, direction:Transition.OUT, duration:0.5, easing:Strong.easeOut});
  19. }
  20.  
  21. display.addEventListener(VideoEvent.PLAYING_STATE_ ENTERED, onPlayerBuffered);
  22.  
  23. //Display the mcBufferingIndicator when buffering.
  24. function onPlayerNotBuffered(event:VideoEvent)
  25. {
  26. mcBufferingIndicator.visible = true;
  27. }
  28. display.addEventListener(VideoEvent.BUFFERING_STAT E_ENTERED, onPlayerNotBuffered);
  29.  
  30. // Create event handler functions to control the progressbar
  31. function progressHandler(event:VideoProgressEvent):void
  32. {
  33. var bl = Math.round(event.bytesLoaded/1000);
  34. var bt = Math.round(event.bytesTotal/1000);
  35.  
  36. // Update progress...
  37. pb.setProgress(bl,bt);
  38. }
  39.  
  40. function readyHandler(event:VideoEvent):void
  41. {
  42. // Remove progressbar when we start playing...
  43. removeChild(pb);
  44. }
  45.  
  46. // Set progress bar state
  47. pb.mode = ProgressBarMode.MANUAL;
  48. pb.indeterminate = false;
  49.  
  50. // Add listeners and load the video
  51. flvControl.addEventListener(VideoProgressEvent.PRO GRESS, progressHandler);
  52. flvControl.addEventListener(VideoEvent.READY, readyHandler);
  53. flvControl.source = flvSource;
  54.  



I am getting the following errors:

The class or interface 'VideoEvent' could not be loaded.
Source: function onPlayerBuffered(event:VideoEvent)

The class or interface 'VideoEvent' could not be loaded.
Source: function onPlayerNotBuffered(event:VideoEvent)

The class or interface 'VideoProgressEvent' could not be loaded.
Source: function progressHandler(event:VideoProgressEvent):void

The class or interface 'VideoEvent' could not be loaded.
Source: function readyHandler(event:VideoEvent):void

Any help appreciated
Moderator Remark: Use [code][/code] to encapsulate code segments
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 28th, 2009, 4:40 am

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post July 28th, 2009, 6:27 am

Are you compiling as AS3 or AS2? (needs to be AS3)

Also are you using Flex or Flash?
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • kfc06
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 28, 2009
  • Posts: 12
  • Status: Offline

Post July 28th, 2009, 8:45 am

Hi thanks for the help,

I am using Flash and i tried converting to AS3 and the flv component said it needed AS2. So i redone from scratch in AS3 dragging a new flv playback component onto the stage and inserted the code again, now getting different errors:

ERROR1
1084: Syntax error: expecting rightparen before ENTERED.
SOURCE: display.addEventListener(VideoEvent.PLAYING_STATE_ ENTERED, onPlayerBuffered);

ERROR 2
1084: Syntax error: expecting rightparen before E_ENTERED.
display.addEventListener(VideoEvent.BUFFERING_STAT E_ENTERED, onPlayerNotBuffered);

ERROR 3
1084: Syntax error: expecting rightparen before GRESS.
flvControl.addEventListener(VideoProgressEvent.PRO GRESS, progressHandler);
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Joined: Jul 25, 2005
  • Posts: 2735
  • Loc: Nashville, TN
  • Status: Offline

Post July 28th, 2009, 9:05 am

kfc06, you have space in every line that's breaking up the constant. Try it without, like below.

Code: [ Select ]
display.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, onPlayerBuffered);

display.addEventListener(VideoEvent.BUFFERING_STATE_ENTERED, onPlayerNotBuffered);

flvControl.addEventListener(VideoProgressEvent.PROGRESS, progressHandler);
  1. display.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, onPlayerBuffered);
  2. display.addEventListener(VideoEvent.BUFFERING_STATE_ENTERED, onPlayerNotBuffered);
  3. flvControl.addEventListener(VideoProgressEvent.PROGRESS, progressHandler);
I'd love to change the world, but they won't give me the source code.
  • kfc06
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 28, 2009
  • Posts: 12
  • Status: Offline

Post July 28th, 2009, 9:26 am

argh...ok thanks for the spot, I took out the spaces and now got the following:
1120: Access of undefined property mcBufferingIndicator
1120: Access of undefined property display
1120: Access of undefined property progressHandler
1120: Access of undefined property readyHandler
1058: Migrationissue The property_rotation is no longer supported. Use the DisplayObject.rotation property instead..
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post July 28th, 2009, 1:30 pm

Think your problem may be partially my fault. I just looked back at my original post and it doesn't appear that I ever actually posted the finished code that worked perfectly for me. I compared yours to mine and realized I had commented out a lot of what you still have in yours.

This is the code I ended up with (Note the lines that are commented out)
Code: [ Select ]
import fl.video.*;
//import fl.controls.ProgressBarMode;
import fl.transitions.*;
import fl.transitions.easing.*;
 
 
// Set Variables
var flvControl = display;
var flvSource = "solo01.flv";
 
display.bufferTime = 1;
 
//fade the mcBufferingIndicator when buffered.
function onPlayerBuffered(event:VideoEvent)
{
   
    TransitionManager.start(mcBufferingIndicator, {type:Fade, direction:Transition.OUT, duration:0.5, easing:Strong.easeOut});
   
}
 
display.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, onPlayerBuffered);
 
//Display the mcBufferingIndicator when buffering.
function onPlayerNotBuffered(event:VideoEvent)
{
mcBufferingIndicator.visible = true;
}
display.addEventListener(VideoEvent.BUFFERING_STATE_ENTERED, onPlayerNotBuffered);
/*
function onPlayerStopped(event:VideoEvent)
{
mcBufferingIndicator.visible = false;
}
display.addEventListener(VideoEvent.STOPPED_STATE_ENTERED, onPlayerStopped);
 
*/
/*
// Create event handler functions to control the progressbar
function progressHandler(event:VideoProgressEvent):void
{
   var bl = Math.round(event.bytesLoaded/1000);
   var bt = Math.round(event.bytesTotal/1000);
 
   // Update progress...
   pb.setProgress(bl,bt);
}
 
function readyHandler(event:VideoEvent):void
{
   // Remove progressbar when we start playing...
   removeChild(pb);
}
 
// Set progress bar state
pb.mode = ProgressBarMode.MANUAL;
pb.indeterminate = false;
*/
// Add listeners and load the video
//flvControl.addEventListener(VideoProgressEvent.PROGRESS, progressHandler);
//flvControl.addEventListener(VideoEvent.READY, readyHandler);
flvControl.source = flvSource;
 
 
 
  1. import fl.video.*;
  2. //import fl.controls.ProgressBarMode;
  3. import fl.transitions.*;
  4. import fl.transitions.easing.*;
  5.  
  6.  
  7. // Set Variables
  8. var flvControl = display;
  9. var flvSource = "solo01.flv";
  10.  
  11. display.bufferTime = 1;
  12.  
  13. //fade the mcBufferingIndicator when buffered.
  14. function onPlayerBuffered(event:VideoEvent)
  15. {
  16.    
  17.     TransitionManager.start(mcBufferingIndicator, {type:Fade, direction:Transition.OUT, duration:0.5, easing:Strong.easeOut});
  18.    
  19. }
  20.  
  21. display.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, onPlayerBuffered);
  22.  
  23. //Display the mcBufferingIndicator when buffering.
  24. function onPlayerNotBuffered(event:VideoEvent)
  25. {
  26. mcBufferingIndicator.visible = true;
  27. }
  28. display.addEventListener(VideoEvent.BUFFERING_STATE_ENTERED, onPlayerNotBuffered);
  29. /*
  30. function onPlayerStopped(event:VideoEvent)
  31. {
  32. mcBufferingIndicator.visible = false;
  33. }
  34. display.addEventListener(VideoEvent.STOPPED_STATE_ENTERED, onPlayerStopped);
  35.  
  36. */
  37. /*
  38. // Create event handler functions to control the progressbar
  39. function progressHandler(event:VideoProgressEvent):void
  40. {
  41.    var bl = Math.round(event.bytesLoaded/1000);
  42.    var bt = Math.round(event.bytesTotal/1000);
  43.  
  44.    // Update progress...
  45.    pb.setProgress(bl,bt);
  46. }
  47.  
  48. function readyHandler(event:VideoEvent):void
  49. {
  50.    // Remove progressbar when we start playing...
  51.    removeChild(pb);
  52. }
  53.  
  54. // Set progress bar state
  55. pb.mode = ProgressBarMode.MANUAL;
  56. pb.indeterminate = false;
  57. */
  58. // Add listeners and load the video
  59. //flvControl.addEventListener(VideoProgressEvent.PROGRESS, progressHandler);
  60. //flvControl.addEventListener(VideoEvent.READY, readyHandler);
  61. flvControl.source = flvSource;
  62.  
  63.  
  64.  


Working example.
http://www.alaron-nuclear.com/private/m ... olo-5.html

Original post for reference
flash-forum/displaying-buffer-message-with-flvplayback-component-t96761.html
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • kfc06
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 28, 2009
  • Posts: 12
  • Status: Offline

Post July 29th, 2009, 2:29 am

Hi Thanks for this! I think i am making headway, seems not to be erroring now :)

I just have a few small problems now one which to you action script Gurus hopefully should be pretty simple. I had a spinning icon in AS2 and now since it needs to be published in AS3 it has broke....

Has any one idea how i write the following code in AS3:

onEnterFrame = function () {
RP2A._rotation += 15;
};

Thanks
  • kfc06
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 28, 2009
  • Posts: 12
  • Status: Offline

Post July 29th, 2009, 4:08 am

ok got that susssed using:

myMC.addEventListener(Event.ENTER_FRAME,callFunction);

function callFunction(event:Event):void{
myMC.RP2A.rotation += 15;

}

Just one last question hopeefully!! :)

I have the skin using the SkinUnderPlaySeekStop.swf (one provided with the flash component) although when i buffer it shows a terrible green horizontal barbar pole in the seek bar...is there away to hide that now that i have my own indicator?

Thanks
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post July 29th, 2009, 4:42 am

I remember seeing that too, but have no recollection of how I got rid of it.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • kfc06
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 28, 2009
  • Posts: 12
  • Status: Offline

Post July 29th, 2009, 6:00 am

I found the .fla files for the skins in the programme files and changed it there publishing out the new skin without the bars which sorted it.

The only thing i notice now about your sample and the one i have now created is your controls come up just as the video starts whereas mine comes up about a second before the video starts. Any idea how i can hide the controls until the video plays like you have managed to achieve?

PS great work on the forum! I have had more success with you guys than i have Adobe forums.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post July 29th, 2009, 6:56 am

Bigwebmaster did a great job creating and designing this place. There's a lot of very talented people that frequent here.

As far as the controls, I just looked at mine and to me, the controls do come up before the movie starts just like you said yours does. Think that might just be a connection speed kind of thing. Not sure if anything can be done about changing that.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • kfc06
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 28, 2009
  • Posts: 12
  • Status: Offline

Post July 30th, 2009, 7:17 am

I have now got the above code working and am happy with it for when using the skin. Now I am using it to work on flash files that are say 30sec long and then loop on completion. All works good by just adding the below code to get it to loop, but the buffer symbol flicks up at the start of the again and then disappears despite the flash file now being cached.

Is there anyway to stop the buffer symbol showing once it is on repeat? I tried the below but it didn't work (still blinks up and disappears:

display.autoRewind = true;

display.addEventListener( VideoEvent.AUTO_REWOUND, videoPlayAgain, false, 0, true );

function videoPlayAgain( event:VideoEvent ):void
{
event.target.play();
mcBufferingIndicator.visible = false;

}
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post July 30th, 2009, 11:21 am

Where did you put that? At the end? If so try putting it before your other functions.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • kfc06
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 28, 2009
  • Posts: 12
  • Status: Offline

Post July 31st, 2009, 5:32 am

yeah it was at the end, but i put it to the top as suggested but still no luck, i still get a blink at the start of replay...
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post July 31st, 2009, 5:40 am

Try reversing these

Code: [ Select ]
event.target.play();
mcBufferingIndicator.visible = false;
  1. event.target.play();
  2. mcBufferingIndicator.visible = false;


They execute in order top to bottom.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 31st, 2009, 5:40 am

Post Information

  • Total Posts in this topic: 17 posts
  • Users browsing this forum: No registered users and 33 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.