UNPKG

@lanaco/lnc-react-ui

Version:

React component library

2 lines (1 loc) 3.07 kB
"use strict";const v=require("./_commonjsHelpers-DwTZ_eVU.cjs"),D=require("react"),h=require("./SearchSection-CgbZsVg2.cjs");function O(t,e){for(var r=0;r<e.length;r++){const a=e[r];if(typeof a!="string"&&!Array.isArray(a)){for(const o in a)if(o!=="default"&&!(o in t)){const i=Object.getOwnPropertyDescriptor(a,o);i&&Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:()=>a[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var b=Object.create,s=Object.defineProperty,M=Object.getOwnPropertyDescriptor,w=Object.getOwnPropertyNames,S=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty,T=(t,e,r)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,A=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},d=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of w(e))!j.call(t,o)&&o!==r&&s(t,o,{get:()=>e[o],enumerable:!(a=M(e,o))||a.enumerable});return t},E=(t,e,r)=>(r=t!=null?b(S(t)):{},d(!t||!t.__esModule?s(r,"default",{value:t,enumerable:!0}):r,t)),L=t=>d(s({},"__esModule",{value:!0}),t),n=(t,e,r)=>(T(t,typeof e!="symbol"?e+"":e,r),r),_={};A(_,{default:()=>p});var f=L(_),c=E(D),l=h.utils,g=h.patterns;const C="https://api.dmcdn.net/all.js",N="DM",R="dmAsyncInit";class p extends c.Component{constructor(){super(...arguments),n(this,"callPlayer",l.callPlayer),n(this,"onDurationChange",()=>{const e=this.getDuration();this.props.onDuration(e)}),n(this,"mute",()=>{this.callPlayer("setMuted",!0)}),n(this,"unmute",()=>{this.callPlayer("setMuted",!1)}),n(this,"ref",e=>{this.container=e})}componentDidMount(){this.props.onMount&&this.props.onMount(this)}load(e){const{controls:r,config:a,onError:o,playing:i}=this.props,[,y]=e.match(g.MATCH_URL_DAILYMOTION);if(this.player){this.player.load(y,{start:(0,l.parseStartTime)(e),autoplay:i});return}(0,l.getSDK)(C,N,R,u=>u.player).then(u=>{if(!this.container)return;const m=u.player;this.player=new m(this.container,{width:"100%",height:"100%",video:y,params:{controls:r,autoplay:this.props.playing,mute:this.props.muted,start:(0,l.parseStartTime)(e),origin:window.location.origin,...a.params},events:{apiready:this.props.onReady,seeked:()=>this.props.onSeek(this.player.currentTime),video_end:this.props.onEnded,durationchange:this.onDurationChange,pause:this.props.onPause,playing:this.props.onPlay,waiting:this.props.onBuffer,error:P=>o(P)}})},o)}play(){this.callPlayer("play")}pause(){this.callPlayer("pause")}stop(){}seekTo(e,r=!0){this.callPlayer("seek",e),r||this.pause()}setVolume(e){this.callPlayer("setVolume",e)}getDuration(){return this.player.duration||null}getCurrentTime(){return this.player.currentTime}getSecondsLoaded(){return this.player.bufferedTime}render(){const{display:e}=this.props,r={width:"100%",height:"100%",display:e};return c.default.createElement("div",{style:r},c.default.createElement("div",{ref:this.ref}))}}n(p,"displayName","DailyMotion");n(p,"canPlay",g.canPlay.dailymotion);n(p,"loopOnEnded",!0);const x=v.getDefaultExportFromCjs(f),K=O({__proto__:null,default:x},[f]);exports.DailyMotion=K;