Jump to content
GreenSock

jguthrie

When calling videoLoader.playVideo(), vid wont play

Recommended Posts

This seems to happen on and off. As in I will publish it, press play and it works fine. Other times I will publish it, press play and it wont play.

 

I am using Flash CS 5.5, 11.5.1, publishing for Flash Player 10 and 10.1. I am listening for netstatus events but am not sure how to troubleshoot things. Any advice?

Link to comment
Share on other sites

Pretty tough to troubleshoot blind, but I can't recall ever hearing about this issue so I wonder if something else is going on in your code. And are you sure the video has loaded adequately when you're trying to play it? Maybe it just looks like it's not playing because it's still buffering?

 

You're using the latest version of LoaderMax/VideoLoader, right?

Link to comment
Share on other sites

Yes it should be the latest as I have downloaded the swc from you (in the my account section) just a few days ago.

 

The buffer trace says its full when i start to play. (vid loads instantly as i am running locally)...

 

I think it had something to do with calling the CasaMovieClip.destroy() method. The code below is a bit old. What I did was move the playVideo() to be the last thing in the playPauseHandler() and I have not had the problem since...

 

Here's my code:

 

private var _videoLoader:VideoLoader;
private function init ():void {
loadVideo();
_sVideoHolder.alpha = 0;

		_sPlayButton.addEventListener (MouseEvent.CLICK, playPauseHandler);
		_sPlayButton.buttonMode = true;
}

protected function loadVideo():void {
_videoLoader = new VideoLoader("../video/myvid.f4v", {name:"theVideo", container:_sVideoHolder, width:960, height:540, autoPlay:false, volume:1, bufferTime: 10, smoothing:true, requireWithRoot:this.root, onError: videoErrorHandler, onFail: videoFailHandler, onProgress:videoProgressHandler, onComplete:videoCompleteHandler, onHTTPStatus:videoHTTPStatus} );
		_videoLoader.addEventListener(VideoLoader.VIDEO_CUE_POINT, videoCuePointHandler);
		_videoLoader.addEventListener(NetStatusEvent.NET_STATUS, videoNetStatusHandler);
		_videoLoader.load();
	}

protected function playPauseHandler (event:MouseEvent):void {
		//trace('playPauseHandler');
		if(_firstClick) {
			onFirstClick();
			_videoLoader.playVideo();
		} else {
			_videoLoader.videoPaused = !_videoLoader.videoPaused;
		}
		animatePlayButtonOut();
		clearAnimations();
	}
protected function onFirstClick():void {
		//trace('onFirstClick');
		_sVideoHolder.alpha = 1;
		_firstClick = false;
		removeChild(_sSponsorButton);
		removeChild(_sSplashScreen);
	}
protected function clearAnimations():void {
		try {
			CasaMovieClip(_sAnimationHolder.getChildByName(_currentAnimation)).destroy();
			//_sAnimationHolder.removeChild(_sAnimationHolder.getChildByName(_currentAnimation));
			trace('clearAnimations: removed child');
		} catch(e:Error) {
			trace('clearAnimations: no firstChildExists');
		}
	}

Link to comment
Share on other sites

I resolved this but figured I would post my hypothesis in case it helps someone.

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.
×