Skip to content

Instantly share code, notes, and snippets.

@adamwalter
Last active April 13, 2021 15:26
Show Gist options
  • Save adamwalter/f49f70d34e93c2ff18e214270daad289 to your computer and use it in GitHub Desktop.
Save adamwalter/f49f70d34e93c2ff18e214270daad289 to your computer and use it in GitHub Desktop.
Wistia Crop-Fill Plugin
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/assets/es3/";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(561);
/***/ },
/***/ 561:
/***/ function(module, exports) {
!function(t){var e,i,n,r,a,o;return a=t.lib("player/lib/elem"),r=a.elemWidth,n=a.elemHeight,o=t.lib("player/lib/timeout-utils"),i=o.doTimeout,e=o.clearTimeouts,t.plugin("cropFill",function(a,o){var l,u,c,s,h,d,p,f;return p=null,a.hasData(function(){var e;return e=t.Video.stillAsset(a._mediaData),p=e.width/e.height}),h=a.container.parentNode,h===document.body||/absolute|fixed|relative/.test(h.style.position)||(h.style.position="relative",h.style.overflow="hidden"),a.container.style.position="absolute",s=function(){var t,e,i,o,l;return l=r(h),o=n(h),i=l/o,i>p?(a.width(l,{constrain:!0}),e=-(a.height()-o)/2,a.container.style.top=Math.round(e)+"px",a.container.style.left="0px"):(a.height(o,{constrain:!0}),t=-(a.width()-l)/2,a.container.style.left=Math.round(t)+"px",a.container.style.top="0px")},l=function(){return i(a.uuid+".cropFill.resize",s,50)},c=r(h),u=n(h),f=function(){var t,e;return e=r(h),t=n(h),c!==e?(s(),c=e):u!==t&&(s(),u=t),i(a.uuid+".cropFill.watchTarget",f,500)},d=function(){return e(a.uuid+".cropFill.watchTarget")},f(),a.bind("widthchange",l),a.bind("heightchange",l),a.hasData(s),{resize:s,watch:f,unwatch:d}})}(Wistia);
/***/ }
/******/ });
embedVideo: function() {
var videoOptions = {};
// Add the crop fill plugin to the videoOptions
Object.assign(videoOptions, {
plugin: {
cropFill: {
src: "//example.com/path-to/wistia-crop-fill.js"
}
}
});
// Video in the background
wistiaEmbed = Wistia.embed(fullScreenVideo.backgroundVideo, videoOptions);
// Video to be shown in the overlay
overlayEmbed = Wistia.embed(fullScreenVideo.overlayVideo, videoOptions);
// We load the thumbnail in the background while we wait
// for the video to load and play. Once loaded, we pause, reset to
// frame zero, show the video then play it.
wistiaEmbed.bind('play', function() {
wistiaEmbed.pause();
wistiaEmbed.time(0);
$(fullScreenVideo.backgroundVideoDiv).css(’visibility’, ’visible’);
wistiaEmbed.play();
return this.unbind;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment