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

Improving the projection of video by setting videoElement style #6038

Merged
merged 3 commits into from Jan 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/layer/VideoOverlay.js
Expand Up @@ -32,7 +32,12 @@ export var VideoOverlay = ImageOverlay.extend({

// @option loop: Boolean = true
// Whether the video will loop back to the beginning when played.
loop: true
loop: true,

// @option keepAspectRatio: Boolean = true
// Whether the video will save aspect ratio after the projection.
// Relevant for supported browsers. Browser compatibility- https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
keepAspectRatio: true
},

_initImage: function () {
Expand Down Expand Up @@ -62,6 +67,7 @@ export var VideoOverlay = ImageOverlay.extend({

if (!Util.isArray(this._url)) { this._url = [this._url]; }

if (!this.options.keepAspectRatio && vid.style.hasOwnProperty('objectFit')) { vid.style['objectFit'] = 'fill'; }
vid.autoplay = !!this.options.autoplay;
vid.loop = !!this.options.loop;
for (var i = 0; i < this._url.length; i++) {
Expand Down