Jump to content
GreenSock

seddass

VideoLoader - video plays after unload & dispose(true)

Recommended Posts

Hello guys,

I have searched a lot in the forum and I have spend hours but I still cant find the answer.

 

The question is..

How to remove/kill/unload/dispose/erase VideoLoader when the video is buffering?

 

My problem is when I load a video in VideoLoader and while the video is still buffering and i call video unload() and/or dispose(true) the sound of the video start playing after all. Below is my code I am using. If I call disposeVideo() WHILE the video is buffering.. the sound of the video starts to play in a background after the video is buffered. Probably it is not only the sound that is played. :)

Hope for help.

Thanks.

 

function loadVideo():void {
   var videoConfig : Object = {name:"HomeVideo", width:506, height:285, scaleMode:"stretch", bgColor:0x000000, autoPlay:false, volume:0};
   _video = new VideoLoader("myVideo.flv", videoConfig);
   _video.load();
   _video.gotoVideoTime(0, true);
   ...
   added some listeners...
}

function disposeVideo() : void {
if (_video.videoPaused) reinitPlayPause();
TweenMax.to(preloader_mc, 0.2, {autoAlpha:0, onComplete:preloader_mc.stop});
TweenMax.to(_video.content, 0.2, {autoAlpha:0});
_video.removeEventListener(VideoLoader.VIDEO_BUFFER_FULL, bufferFullHandler);
_video.removeEventListener(NetStatusEvent.NET_STATUS, onNetStatusChange);			
videoContainer_mc.removeChild(_video.content);
TweenMax.to(_video, 0.2, {volume:0, onComplete: function():void {
	_video.pauseVideo();
	_video.unload();
	_video.dispose(true);
}});
}

Link to comment
Share on other sites

You seem to have a lot of unnecessary code in there that could confuse things. For example, why do you have autoPlay:false and then you gotoVideo(0, true) immediately after you load? Why not just set autoPlay:true? And why do you pauseVideo() and unload() and dispose(true) instead of simply dispose(true)? Also, you're using an anonymous function to do the pause/unload/dispose but anonymous functions in Flash can cause some headaches and I wonder if you're running into a scope problem. This is how I'd clean things up from your code:

 

    function loadVideo():void {
       var videoConfig : Object = {name:"HomeVideo", width:506, height:285, scaleMode:"stretch", bgColor:0x000000, autoPlay:true, volume:0};
       _video = new VideoLoader("myVideo.flv", videoConfig);
       _video.load();
       ...
       added some listeners...
   }

   function disposeVideo() : void {
      if (_video.videoPaused) reinitPlayPause();
      TweenMax.to(preloader_mc, 0.2, {autoAlpha:0, onComplete:preloader_mc.stop});
      TweenMax.to(_video.content, 0.2, {autoAlpha:0});
      _video.removeEventListener(VideoLoader.VIDEO_BUFFER_FULL, bufferFullHandler);
      _video.removeEventListener(NetStatusEvent.NET_STATUS, onNetStatusChange);         
      TweenMax.to(_video, 0.2, {volume:0, onComplete:_video.dispose, onCompleteParams:[true]});
   }

 

If that doesn't help, please post a very simple FLA that demonstrates the behavior so that we can publish it on our end and see exactly what's going on. I'm sure we can get this figured out.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×