aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plugins/vimeo.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2020-10-19 22:26:33 +1100
committerSam Potts <sam@potts.es>2020-10-19 22:26:33 +1100
commit776b0c40367e7a184eb7db2673c246048cb5fcb8 (patch)
tree5baff2f7eeb3a2594a3ab16c48410169c63feedb /src/js/plugins/vimeo.js
parentfa653a8859a4191d30d90f0b560bbb4c5c3b83ac (diff)
downloadplyr-776b0c40367e7a184eb7db2673c246048cb5fcb8.tar.lz
plyr-776b0c40367e7a184eb7db2673c246048cb5fcb8.tar.xz
plyr-776b0c40367e7a184eb7db2673c246048cb5fcb8.zip
feat: custom controls option for embedded players
Diffstat (limited to 'src/js/plugins/vimeo.js')
-rw-r--r--src/js/plugins/vimeo.js38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/js/plugins/vimeo.js b/src/js/plugins/vimeo.js
index 2e12d160..cd19b097 100644
--- a/src/js/plugins/vimeo.js
+++ b/src/js/plugins/vimeo.js
@@ -112,31 +112,35 @@ const vimeo = {
}
// Inject the package
- const { poster } = player;
- if (premium) {
- iframe.setAttribute('data-poster', poster);
+ if (premium || !config.customControls) {
+ iframe.setAttribute('data-poster', player.poster);
player.media = replaceElement(iframe, player.media);
} else {
- const wrapper = createElement('div', { class: player.config.classNames.embedContainer, 'data-poster': poster });
+ const wrapper = createElement('div', {
+ class: player.config.classNames.embedContainer,
+ 'data-poster': player.poster,
+ });
wrapper.appendChild(iframe);
player.media = replaceElement(wrapper, player.media);
}
// Get poster image
- fetch(format(player.config.urls.vimeo.api, id), 'json').then((response) => {
- if (is.empty(response)) {
- return;
- }
+ if (!config.customControls) {
+ fetch(format(player.config.urls.vimeo.api, id), 'json').then((response) => {
+ if (is.empty(response)) {
+ return;
+ }
- // Get the URL for thumbnail
- const url = new URL(response[0].thumbnail_large);
+ // Get the URL for thumbnail
+ const url = new URL(response[0].thumbnail_large);
- // Get original image
- url.pathname = `${url.pathname.split('_')[0]}.jpg`;
+ // Get original image
+ url.pathname = `${url.pathname.split('_')[0]}.jpg`;
- // Set and show poster
- ui.setPoster.call(player, url.href).catch(() => {});
- });
+ // Set and show poster
+ ui.setPoster.call(player, url.href).catch(() => {});
+ });
+ }
// Setup instance
// https://github.com/vimeo/player.js
@@ -407,7 +411,9 @@ const vimeo = {
});
// Rebuild UI
- setTimeout(() => ui.build.call(player), 0);
+ if (config.customControls) {
+ setTimeout(() => ui.build.call(player), 0);
+ }
},
};