Jump to content
Search Community

Display a buffering icon if the video gets to buffered...

jguthrie test
Moderator Tag

Recommended Posts

Yes it does. But the video would resume playing before the VideoLoader becames empty correct?

Resume playing before it becomes empty? The buffer? Sorry, I'm having a hard time understanding what you're asking here. Could you rephrase the question?

 

As far as testing this goes, would it be best to use Charles to simulate a slow connection speed?

I use NetLimiter, but maybe Charles would be good too (I'm not sure).

Link to comment
Share on other sites

But the video would resume playing before the VideoLoader becames empty correct?

 

Sorry I should have wrote:

But the video would resume playing before the buffer became full correct? I have the initial buffering amount set at 20 secs so would that mean it would wait to buffer another 20 secs before playing?

 

I just want to know when to show/hide my 'buffering animation'.

 

Thanks!

Link to comment
Share on other sites

Yes and yes.

 

You can set/change the netStream.bufferTime anytime you want. Also note that by default, autoAdjustBuffer is true which means that if/when it runs out of buffer, it will automatically attempt to adjust the NetStream's bufferTime based on the rate at which the video has been loading, estimating what it needs to be in order to play the rest of the video without emptying the buffer again. You can turn that off if you want, but it's a great feature for preventing jerky playback.

Link to comment
Share on other sites

Would there be anything that would cause the buffer to empty (and subsequently fire the "NetStream.Buffer.Empty" event) when the video finishes playing? I can play the video 2 or 3 times but eventually the buffer will empty, at which point the buffering screen shows. (Because I want to show this when the vid needs to buffer)

 

//for loading video
protected function loadVideo():void {
		_sVideoHolder.alpha = 0;
		_videoLoader = new VideoLoader(_videoUrl, {name:"theVideo", container:_sVideoHolder, width:960, height:540, autoPlay:false, volume:1, bufferMode:true, bufferTime: 20, 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();
	}

//for responding to events
protected function videoNetStatusHandler (event:LoaderEvent):void {

		MonsterDebugger.trace(this, 'ChristmasCampaignVideo.videoNetStatusHandler event: ' + event);
		MonsterDebugger.trace(this, 'ChristmasCampaignVideo.videoNetStatusHandler: ' + event.data.code);
		switch (event.data.code) {

			case "NetStream.Play.Start" :

				break;

			case "NetStream.Buffer.Empty" :
				trace('videoNetStatusHandler, VIDEO_BUFFER_EMPTY _currentAnimation: ' + _currentAnimation);

					_bufferButtonTimeline.play();
					_sBufferScreen.visible = true;

				MonsterDebugger.trace(this, 'videoNetStatusHandler, VIDEO_BUFFER_EMPTY');
				break;

			case "NetStream.Play.Stop" :

				break;

			case "NetStream.Buffer.Full" :
				_bufferButtonTimeline.stop();
				_sBufferScreen.visible = false;
				trace('videoNetStatusHandler, VIDEO_BUFFER_FULL');
				MonsterDebugger.trace(this, 'videoNetStatusHandler, VIDEO_BUFFER_FULL');
				break;

			case "NetStream.Buffer.Flush" :

				break;

			case "NetStream.Seek.InvalidTime" :

				break;
		}

Link to comment
Share on other sites

I'm not sure - I don't see that behavior. Could you post a sample set of files (including your video) so that I can compile and test on my end? The simpler the better.

 

I'm curious why you're listening for the NetStatus events instead of just letting VideoLoader do that job for you. You can simply listen for VideoLoader's VideoLoader.VIDEO_BUFFER_EMPTY and VideoLoader.VIDEO_BUFFER_FULL events. Not that it's "wrong" to do it the way you're doing it. Just curious.

Link to comment
Share on other sites

Yes I can try to get some sample files to you. (I will email them)

 

No reason in particular (but that may be my problem) just that I saw that code on a post somewhere and used it... Would you recommend I do this?

_videoLoader.addEventListener(VideoLoader.VIDEO_BUFFER_EMPTY, videoBufferEmpty);
		_videoLoader.addEventListener(VideoLoader.VIDEO_BUFFER_FULL, videoBufferFull);
protected function videoBufferEmpty(event:LoaderEvent):void
	{
		trace('videoBufferEmpty');
	}

	protected function videoBufferFull(event:LoaderEvent):void
	{
		trace('videoBufferFull');
	}

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.
×
×
  • Create New...