-
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
Add built-in Picture-in-Picture button #6002
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
82847f0
Add Picture-in-Picture API methods
beaufortfrancois 44d09fc
Add abstract method to tech.js
beaufortfrancois 75de129
Add Picture-in-Picture control bar button
beaufortfrancois a2012c2
Use [email protected]
beaufortfrancois 43388f8
Make fullscreen toggle button right-most button
beaufortfrancois efe840d
Add Promise to options
beaufortfrancois 14d27fe
Merge branch 'pip-api-methods' into pip-button
beaufortfrancois 3aaaa20
Merge branch 'master' of github.com:videojs/video.js into pip-button
beaufortfrancois ac963be
Place PiP before fullscreen everywhere
beaufortfrancois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.video-js .vjs-picture-in-picture-control { | ||
cursor: pointer; | ||
@include flex(none); | ||
|
||
& .vjs-icon-placeholder { | ||
@extend .vjs-icon-picture-in-picture-enter; | ||
} | ||
} | ||
// Switch to the exit icon when the player is in Picture-in-Picture | ||
.video-js.vjs-picture-in-picture .vjs-picture-in-picture-control .vjs-icon-placeholder { | ||
@extend .vjs-icon-picture-in-picture-exit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* @file picture-in-picture-toggle.js | ||
*/ | ||
import Button from '../button.js'; | ||
import Component from '../component.js'; | ||
import document from 'global/document'; | ||
|
||
/** | ||
* Toggle Picture-in-Picture mode | ||
* | ||
* @extends Button | ||
*/ | ||
class PictureInPictureToggle extends Button { | ||
|
||
/** | ||
* Creates an instance of this class. | ||
* | ||
* @param {Player} player | ||
* The `Player` that this class should be attached to. | ||
* | ||
* @param {Object} [options] | ||
* The key/value store of player options. | ||
*/ | ||
constructor(player, options) { | ||
super(player, options); | ||
this.on(player, 'pictureinpicturechange', this.handlePictureInPictureChange); | ||
|
||
// TODO: Activate button on player loadedmetadata event. | ||
// TODO: Deactivate button on player emptied event. | ||
// TODO: Deactivate button if disablepictureinpicture attribute is present. | ||
if (!document.pictureInPictureEnabled) { | ||
this.disable(); | ||
} | ||
} | ||
|
||
/** | ||
* Builds the default DOM `className`. | ||
* | ||
* @return {string} | ||
* The DOM `className` for this object. | ||
*/ | ||
buildCSSClass() { | ||
return `vjs-picture-in-picture-control ${super.buildCSSClass()}`; | ||
} | ||
|
||
/** | ||
* Handles pictureinpicturechange on the player and change control text accordingly. | ||
* | ||
* @param {EventTarget~Event} [event] | ||
* The {@link Player#pictureinpicturechange} event that caused this function to be | ||
* called. | ||
* | ||
* @listens Player#pictureinpicturechange | ||
*/ | ||
handlePictureInPictureChange(event) { | ||
if (this.player_.isInPictureInPicture()) { | ||
this.controlText('Exit Picture-in-Picture'); | ||
} else { | ||
this.controlText('Picture-in-Picture'); | ||
} | ||
} | ||
|
||
/** | ||
* This gets called when an `PictureInPictureToggle` is "clicked". See | ||
* {@link ClickableComponent} for more detailed information on what a click can be. | ||
* | ||
* @param {EventTarget~Event} [event] | ||
* The `keydown`, `tap`, or `click` event that caused this function to be | ||
* called. | ||
* | ||
* @listens tap | ||
* @listens click | ||
*/ | ||
handleClick(event) { | ||
if (!this.player_.isInPictureInPicture()) { | ||
this.player_.requestPictureInPicture(); | ||
} else { | ||
this.player_.exitPictureInPicture(); | ||
} | ||
} | ||
|
||
} | ||
|
||
/** | ||
* The text that should display over the `PictureInPictureToggle`s controls. Added for localization. | ||
* | ||
* @type {string} | ||
* @private | ||
*/ | ||
PictureInPictureToggle.prototype.controlText_ = 'Picture-in-Picture'; | ||
|
||
Component.registerComponent('PictureInPictureToggle', PictureInPictureToggle); | ||
export default PictureInPictureToggle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'd expect the fullscreen toggle to still be the right-most button, so, this would have to go above it.
I'm still a bit concerned on whether this can have issues, particularly in ad-plugins that often create their own control bar if it's included by default.
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.
Fullscreen toggle button is now the right-most button. I've updated screenshot as well.