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

Add playsInline attribute on the video element #7928

Merged
merged 6 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add option playsInline
  • Loading branch information
Falke-Design committed Jan 20, 2022
commit 0d0d2b8a1af8a8b347a0aeda768acd8b9ec95eba
5 changes: 4 additions & 1 deletion debug/map/videooverlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
var overlay = L.videoOverlay(videoUrls, bounds, {
opacity: 0.8,
interactive: true,
autoplay: false
autoplay: true,
loop: true,
muted: true,
playsInline: true
});
map.addLayer(overlay);

Expand Down
34 changes: 34 additions & 0 deletions spec/suites/layer/VideoOverlaySpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
describe('ImageOverlay', function () {
var c, map;
var videoBounds = L.latLngBounds([[ 32, -130], [ 13, -100]]);

beforeEach(function () {
c = document.createElement('div');
c.style.width = '400px';
c.style.height = '400px';
document.body.appendChild(c);
map = new L.Map(c);
map.setView(new L.LatLng(55.8, 37.6), 6); // view needs to be set so when layer is added it is initilized
});

afterEach(function () {
map.remove();
map = null;
document.body.removeChild(c);
});

it('create VideoOverlay', function () {
var overlay = L.imageOverlay().setStyle({opacity: 0.5});
expect(overlay.options.opacity).to.equal(0.5);


var videoUrls = [
'https://www.mapbox.com/bites/00188/patricia_nasa.webm',
'https://www.mapbox.com/bites/00188/patricia_nasa.mp4'
];

var videoOverlay = L.videoOverlay(videoUrls, videoBounds).addTo(map);

expect(map.hasLayer(videoOverlay)).to.be.ok();
});
});
9 changes: 7 additions & 2 deletions src/layer/VideoOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export var VideoOverlay = ImageOverlay.extend({
options: {
// @option autoplay: Boolean = true
// Whether the video starts playing automatically when loaded.
// On some browsers autoplay will only work with `muted: true`
autoplay: true,

// @option loop: Boolean = true
Expand All @@ -41,7 +42,11 @@ export var VideoOverlay = ImageOverlay.extend({

// @option muted: Boolean = false
// Whether the video starts on mute when loaded.
muted: false
muted: false,

// @option playsInline: Boolean = true
// Mobile browsers will play the video right where it is instead of open it up in fullscreen mode.
playsInline: true
},

_initImage: function () {
Expand Down Expand Up @@ -78,7 +83,7 @@ export var VideoOverlay = ImageOverlay.extend({
vid.autoplay = !!this.options.autoplay;
vid.loop = !!this.options.loop;
vid.muted = !!this.options.muted;
vid.playsInline = true;
vid.playsInline = !!this.options.playsInline;
for (var i = 0; i < this._url.length; i++) {
var source = DomUtil.create('source');
source.src = this._url[i];
Expand Down