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

Inherit tech 'features' from 'MediaTechController' #1412

Closed
wants to merge 3 commits into from

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented Aug 11, 2014

Use vjs.obj.create to inherit 'features' from
'MediaTechController.prototype.features'. Because we are inheriting, if
the defaults change (prototype.features), we can receive these updates
in our tech if we had not changed properties of features manually.

This fixes #1407.

Use vjs.obj.create to inherit 'features' from
'MediaTechController.prototype.features'. Because we are inheriting, if
the defaults change (prototype.features), we can receive these updates
in our tech if we had not changed properties of features manually.
@heff
Copy link
Member

heff commented Aug 11, 2014

Can you test to make sure this works with the different uses of features?

@heff
Copy link
Member

heff commented Aug 11, 2014

i.e. I think the html5 tech usage needs some modification

@jnwng
Copy link
Contributor

jnwng commented Aug 11, 2014

ugh, sorry, i had actually stumbled upon this many months ago but wasn't sure about how to get a good use case for assigning this.features since my use case was switching techs

coursera@e90a154

i think @gkatsev's change does the same thing in a much less fragile way

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

@heff I think it works correctly. I had a flash and an html player on the page and both work perfectly now.
Anything with the html5 tech I should check out specifically?

@heff
Copy link
Member

heff commented Aug 12, 2014

The use of features in the HTML5 tech before MediaTechController is called.

this.features['volumeControl'] = vjs.Html5.canControlVolume();

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

Alright, I'll take a look later tonight or tomorrow.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

@heff is there anything keeping those things happening before calling MediaTechController? A quick test to move it down seems to work fine.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

I just did a more thorough test with some android and ios devices as well and moving these 4 lines down to below the MediaTechController call doesn't break anything and works as expected.
@heff let me know if you can think off any problems that moving those lines might cause.

@heff
Copy link
Member

heff commented Aug 12, 2014

Yeah, I can't think of any problems with that. I wish those weren't in the init in the first place actually, but not sure if there's an easy way to do that now.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

Hm... never mind, moving those lines breaks things.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

Yeah, it doesn't work to move the setting below the MediaTechController call.
Things like movingMediaElementInDOM end up not being available.

@heff
Copy link
Member

heff commented Aug 12, 2014

It looks like it's probably because some of those settings need to be set before the createEl function that gets run in the Component init. It looks like a higher level refactor of features is needed.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

One way of fixing it is by passing the overrides in as an option to MediaTechController, which would then apply those this.features after doing the create call. @heff thoughts about that?

@heff
Copy link
Member

heff commented Aug 12, 2014

I think we'd still run into some complication with the defaults on MediaTech with the different this contexts. Or at least we'd have to refer to those directly (vjs.MediaTech...) in order to merge with whatever comes through options.

Another option would be to promote these to direct prototype properties in some way. I think the object is only used for organization currently.
this.featuresVolumeControl = true;
There might be a prettier way to do that.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

Do you mean moving them to the prototype of MediaTechController? If so, we might still run into the same problem because after you set the property, when the object gets created during the .call, the prototype will overwrite the this value.

@heff
Copy link
Member

heff commented Aug 12, 2014

Do you mean moving them to the prototype of MediaTechController?

Yeah. If we do that we can rely on standard prototype inheritance. If everything's added to MediaTech.prototype and Html5.prototype, not added in the init(), then we don't have to worry about .call.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

Ok, I'll try it out.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

Looks like promoting it to the prototype works well.

@@ -161,17 +162,15 @@ vjs.MediaTechController.prototype.onTap = function(){
*/
vjs.MediaTechController.prototype.setPoster = function(){};

vjs.MediaTechController.prototype.features = {
'volumeControl': true,
vjs.MediaTechController.prototype[ 'volumeControl' ] = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

I kept these as strings for now, but I can change it.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

Oops, forgot to update tests.

@gkatsev
Copy link
Member Author

gkatsev commented Aug 12, 2014

The rename was needed because otherwise playbackRate conflicted with the Html5 tech's playbackRate method.

@heff
Copy link
Member

heff commented Aug 13, 2014

Yeah, I was actually thinking we'd leave 'features' or something like it in the property name. features playbackRate or supportsPlaybackRate. tech.volumeControl, for example, isn't the best name for what the property actually is used for.

@heff
Copy link
Member

heff commented Aug 22, 2014

Could you update this so it can merge with @dmlap's change?

@heff
Copy link
Member

heff commented Sep 2, 2014

@gkatsev working on a release. Can you try to finish this up?

@gkatsev
Copy link
Member Author

gkatsev commented Sep 2, 2014

This PR is now obsolete. See #1470.

@gkatsev gkatsev closed this Sep 2, 2014
@gkatsev gkatsev deleted the media-tech-features branch September 2, 2014 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants