-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Native controls updates #2499
Native controls updates #2499
Changes from all commits
5d31bdf
1af6089
80c9ca9
28509f4
ebf758f
92a637a
693ae2e
d9c0263
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,6 +501,7 @@ class Player extends Component { | |
|
||
// Grab tech-specific options from player options and add source and parent element to use. | ||
var techOptions = assign({ | ||
'nativeControlsForTouch': this.options_.nativeControlsForTouch, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pass the option to the tech |
||
'source': source, | ||
'playerId': this.id(), | ||
'techId': `${this.id()}_${techName}_api`, | ||
|
@@ -534,7 +535,6 @@ class Player extends Component { | |
textTrackConverter.jsonToTextTracks(this.textTracksJson_ || [], this.tech); | ||
|
||
this.on(this.tech, 'ready', this.handleTechReady); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no longer needed because we assume if |
||
this.on(this.tech, 'usenativecontrols', this.handleTechUseNativeControls); | ||
|
||
// Listen to every HTML5 events and trigger them back on the player for the plugins | ||
this.on(this.tech, 'loadstart', this.handleTechLoadStart); | ||
|
@@ -564,6 +564,8 @@ class Player extends Component { | |
this.on(this.tech, 'texttrackchange', this.onTextTrackChange); | ||
this.on(this.tech, 'loadedmetadata', this.updateStyleEl_); | ||
|
||
this.usingNativeControls(this.techGet('controls')); | ||
|
||
if (this.controls() && !this.usingNativeControls()) { | ||
this.addTechControlsListeners(); | ||
} | ||
|
@@ -665,16 +667,6 @@ class Player extends Component { | |
} | ||
} | ||
|
||
/** | ||
* Fired when the native controls are used | ||
* | ||
* @private | ||
* @method handleTechUseNativeControls | ||
*/ | ||
handleTechUseNativeControls() { | ||
this.usingNativeControls(true); | ||
} | ||
|
||
/** | ||
* Fired when the user agent begins looking for media data | ||
* | ||
|
@@ -1947,6 +1939,7 @@ class Player extends Component { | |
if (this.usingNativeControls_ !== bool) { | ||
this.usingNativeControls_ = bool; | ||
if (bool) { | ||
this.removeTechControlsListeners(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure to remove these listeners if they got added, otherwise, it will mess things up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wouldn't hurt as a code comment if you feel like adding it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to re-add the listeners if we swap back to non-native controls? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we should also re-add them below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. |
||
this.addClass('vjs-using-native-controls'); | ||
|
||
/** | ||
|
@@ -1959,6 +1952,7 @@ class Player extends Component { | |
*/ | ||
this.trigger('usingnativecontrols'); | ||
} else { | ||
this.addTechControlsListeners(); | ||
this.removeClass('vjs-using-native-controls'); | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,8 +76,10 @@ class Html5 extends Tech { | |
// Our goal should be to get the custom controls on mobile solid everywhere | ||
// so we can remove this all together. Right now this will block custom | ||
// controls on touch enabled laptops like the Chrome Pixel | ||
if (browser.TOUCH_ENABLED && options.nativeControlsForTouch === true) { | ||
this.trigger('usenativecontrols'); | ||
if (browser.TOUCH_ENABLED && options.nativeControlsForTouch === true || | ||
browser.IS_IPHONE || | ||
browser.IS_NATIVE_ANDROID) { | ||
this.setControls(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure controls are set. |
||
} | ||
|
||
this.triggerReady(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is necessarily because otherwise, the
.vjs-no-flex
selector below ends up being more specific than this and sets the control bar's display to table. This avoids using!important
or really strong css selectors.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the limitation here, but I don't think we should say this is an ok thing to do in the stylesheet. It's gonna result in uglier and uglier selectors, and I think we can do better.
important
here over a triple class name. It is after all important that the controls be hidden when the controls are disabled.display
, so you have to do more than just display:table to override it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option to fix this specific issue would be to add a
.vjs-flex
class. Since that's the default behavior it could basically be a noop with no specific styles associated with it (because they're the default), but it would solve specificity problems in situations like this.