Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
Delay ready event until buffered
Browse files Browse the repository at this point in the history
Fixes #959
  • Loading branch information
nnarhinen committed Nov 12, 2015
1 parent 6ae31fb commit ac5bf8e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/as/HLSStreamProvider.as
Expand Up @@ -60,9 +60,6 @@ package {
hls.addEventListener(HLSEvent.MEDIA_TIME, _mediaTimeHandler);
hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, _completeHandler);
hls.addEventListener(HLSEvent.ERROR, _errorHandler);
/*
hls.addEventListener(HLSEvent.PLAYBACK_STATE, _stateHandler);
*/
_video.attachNetStream(hls.stream);
}

Expand Down Expand Up @@ -171,12 +168,11 @@ package {
if (suppressReady) {
suppressReady = false;
} else {
player.fire(Flowplayer.READY, clip);
hls.addEventListener(HLSEvent.PLAYBACK_STATE, _readyStateHandler);
}

hls.stream.play();
if (config.autoplay) {
player.fire(Flowplayer.RESUME, null);
} else {
player.debug("stopping on first frame");
hls.stream.pause();
Expand Down Expand Up @@ -216,6 +212,16 @@ package {
player.fire(Flowplayer.FINISH, null);
};

private function _readyStateHandler(event: HLSEvent) : void {
if (hls.playbackState == HLSPlayStates.PLAYING || hls.playbackState == HLSPlayStates.PAUSED) {
player.fire(Flowplayer.READY, clip);
if (config.autoplay) {
player.fire(Flowplayer.RESUME, null);
}
hls.removeEventListener(HLSEvent.PLAYBACK_STATE, _readyStateHandler);
}
};

private function _errorHandler(event : HLSEvent) : void {
var hlsError : HLSError = event.error;
player.debug("error (code/msg/url):" + hlsError.code + "/" + hlsError.msg + "/" + hlsError.url);
Expand Down

1 comment on commit ac5bf8e

@phloxic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

Please sign in to comment.