-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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 2 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, | ||
'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,7 +1939,9 @@ 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'); | ||
this.techCall('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 we have controls |
||
|
||
/** | ||
* player is using the native device controls | ||
|
@@ -1960,6 +1954,7 @@ class Player extends Component { | |
this.trigger('usingnativecontrols'); | ||
} else { | ||
this.removeClass('vjs-using-native-controls'); | ||
this.techCall('setControls', false); | ||
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. Remove controls if they are no longer needed |
||
|
||
/** | ||
* player is using the custom HTML controls | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ class Html5 extends Tech { | |
// 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'); | ||
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.
pass the option to the tech