Jump to content
Search Community

VideoLoader and autoPlay question

Ahrengot test
Moderator Tag

Recommended Posts

Hey Jack!

 

I'm working on this player http://www.ahrengot.com/playground/circular-scrubbing - It's my custom Video Player (Talking about the Actual Player, not the graphic interface here) built on top of your VideoLoader class with some extended features, getters, events and implemented under my own IVideoPlayer Interface class. It was a real joy to build, because the fundament was so solid, but i discovered something that made me scratch my head:

 

If you set autoPlay:true on a VideoLoader it will dispatch a pause event before it starts playing. Is that how it's supposed to be? I could pop the hood on your VideoLoader and try to followed every single function call from instantiation to playback starts, but chances are i'd miss something. I'm really just looking for the reason why it works this way.

Link to comment
Share on other sites

First of all, cool video player! Glad to hear VideoLoader was helpful.

 

As far as the VIDEO_PAUSE event getting called when autoPlay is set to true, could you send me an example that demonstrates the issue? I can't seem to reproduce it. I just tested it several times and never got the VIDEO_PAUSE event to dispatch. Here's my test code:

 

var vl:VideoLoader = new VideoLoader("assets/video.flv", {container:this, autoPlay:true});
vl.addEventListener(VideoLoader.VIDEO_PAUSE, test);
vl.load();

function test(event:LoaderEvent):void {
trace(event.type+" for "+event.target);
}

 

Are you using the latest version? http://www.greensock.com/loadermax/

Link to comment
Share on other sites

Ha! Turned out to be somewhere else in my code i'd messed up.

 

I use a state setter/getter as an alternative way of toggling play/pause/stop on my player, and whenever the video was ready to start playback i manually set the state to be paused so that the state getter returns an accurate value, i just didn't keep in mind they won't always have autoplay disabled.

 

Simply needed to change this

private function onNetstatus(e:NetStatusEvent):void 
{
if (e.info.code == "NetStream.Play.Start" || _loader.bufferProgress == 1) 
{
	_loader.netStream.removeEventListener(NetStatusEvent.NET_STATUS, onNetstatus);

	state = VideoState.PAUSED;
	dispatchEvent(new VideoPlayerEvent(VideoPlayerEvent.READY));
}
}

to this:

private function onNetstatus(e:NetStatusEvent):void 
{
if (e.info.code == "NetStream.Play.Start" || _loader.bufferProgress == 1) 
{
	_loader.netStream.removeEventListener(NetStatusEvent.NET_STATUS, onNetstatus);

	vars.autoPlay? state = VideoState.PLAYING : state = VideoState.PAUSED;
	dispatchEvent(new VideoPlayerEvent(VideoPlayerEvent.READY));
}
}

 

Sorry 'bout that - I feel so silly :)

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