Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play middleware: only trigger play event when our play middleware terminates #365

Merged
merged 3 commits into from
Apr 30, 2018

Conversation

ldayananda
Copy link
Contributor

@ldayananda ldayananda commented Apr 19, 2018

This ensures that the code in playMiddleware.play does not run if another middleware terminates.

…ads play middleware terminates, and not when another middleware terminates.
@ldayananda ldayananda changed the title [WIP] Play middleware: only trigger play event when our play middleware terminates Play middleware: only trigger play event when our play middleware terminates Apr 19, 2018
src/plugin.js Outdated
@@ -193,6 +193,8 @@ const contribAdsPlugin = function(options) {

// Should we block calls to play on the content player?
_shouldBlockPlay: false,
// Was play blocked by the plugin?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest specifying that this is blocked by middleware

Copy link
Contributor

Choose a reason for hiding this comment

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

So that someone reading it knows what feature it's related to

assert.strictEqual(playSpy.callCount, 0,
'play event should not be triggered');
done();
}, 200);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this timeout replaced by an event handler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe so, as if the play is blocked by another middleware we neither advance in the state machine nor do we start playback. That said, if you have another idea I'm all ears 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it work if it was 0 or 1 ms instead of 200? 200 makes it seem like it's waiting for something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like 1ms was actually enough!

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, that should make it a little less mysterious

@ldayananda
Copy link
Contributor Author

@incompl updated based on comments

@incompl
Copy link
Contributor

incompl commented Apr 19, 2018

LGTM

@rtezera1
Copy link
Contributor

QA: Pass!

@incompl incompl merged commit c9eede3 into master Apr 30, 2018
@incompl incompl deleted the play-middleware-concrete branch April 30, 2018 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants