@wix/video 1.80.0 → 1.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/cjs/Video.stories.js +3 -2
  2. package/dist/cjs/Video.stories.js.map +1 -1
  3. package/dist/cjs/custom-element/utils.js +7 -0
  4. package/dist/cjs/custom-element/utils.js.map +1 -1
  5. package/dist/cjs/storybook/Container.js +33 -9
  6. package/dist/cjs/storybook/Container.js.map +1 -1
  7. package/dist/cjs/storybook/args.js +10 -0
  8. package/dist/cjs/storybook/args.js.map +1 -1
  9. package/dist/esm/Video.stories.js +2 -1
  10. package/dist/esm/Video.stories.js.map +1 -1
  11. package/dist/esm/custom-element/utils.js +7 -0
  12. package/dist/esm/custom-element/utils.js.map +1 -1
  13. package/dist/esm/storybook/Container.js +26 -8
  14. package/dist/esm/storybook/Container.js.map +1 -1
  15. package/dist/esm/storybook/args.js +10 -0
  16. package/dist/esm/storybook/args.js.map +1 -1
  17. package/dist/statics/janet/iframe.html +1 -1
  18. package/dist/statics/janet/{main.f45a6aa8.iframe.bundle.js → main.4e295f79.iframe.bundle.js} +6 -5
  19. package/dist/statics/janet/main.4e295f79.iframe.bundle.js.map +1 -0
  20. package/dist/statics/janet/project.json +1 -1
  21. package/dist/statics/manifest.json +2 -2
  22. package/dist/statics/manifest.min.json +2 -2
  23. package/dist/statics/video.umd.js +2 -2
  24. package/dist/statics/video.umd.js.map +1 -1
  25. package/dist/statics/video.umd.min.js +1 -1
  26. package/dist/statics/video.umd.min.js.map +1 -1
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/dist/types/Video.stories.d.ts +1 -0
  29. package/dist/types/Video.stories.d.ts.map +1 -1
  30. package/dist/types/custom-element/utils.d.ts.map +1 -1
  31. package/dist/types/storybook/Container.d.ts +3 -1
  32. package/dist/types/storybook/Container.d.ts.map +1 -1
  33. package/dist/types/storybook/args.d.ts +10 -0
  34. package/dist/types/storybook/args.d.ts.map +1 -1
  35. package/package.json +4 -4
  36. package/dist/statics/janet/main.f45a6aa8.iframe.bundle.js.map +0 -1
@@ -49,17 +49,18 @@ const Default = args => {
49
49
  return /*#__PURE__*/_react.default.createElement(_Container.Container, {
50
50
  width: args.containerWidth,
51
51
  height: args.containerHeight,
52
+ fullscreen: args.fullscreen,
52
53
  __self: void 0,
53
54
  __source: {
54
55
  fileName: _jsxFileName,
55
- lineNumber: 63,
56
+ lineNumber: 64,
56
57
  columnNumber: 5
57
58
  }
58
59
  }, /*#__PURE__*/_react.default.createElement(_index.Video, (0, _extends2.default)({}, videoProps, {
59
60
  __self: void 0,
60
61
  __source: {
61
62
  fileName: _jsxFileName,
62
- lineNumber: 64,
63
+ lineNumber: 69,
63
64
  columnNumber: 7
64
65
  }
65
66
  })));
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_index","_Container","_args","_jsxFileName","openExperiments","urlParams","URLSearchParams","window","location","search","experimentsParam","get","split","forEach","experiment","push","_default","exports","default","title","component","Video","argTypes","Default","args","id","videoRef","React","useRef","useEffect","current","load","autoplay","qualityPolicy","videoProps","loop","Boolean","muted","playbackRate","posterEffect","videoMedia","sampleVideo","focalPoint","x","focalPointX","y","focalPointY","onError","error","console","log","createElement","Container","width","containerWidth","height","containerHeight","__self","__source","fileName","lineNumber","columnNumber","_extends2"],"sources":["../../src/Video.stories.tsx"],"sourcesContent":["import React from 'react';\nimport { Meta } from '@wix/yoshi-storybook-dependencies';\nimport { Video } from './index';\nimport { Container } from './storybook/Container';\nimport { argTypes, sampleVideo } from './storybook/args';\nimport type { QualityPolicy, VideoProps } from './types';\n\nconst openExperiments: string[] = [];\n\nconst urlParams = new URLSearchParams(window.location.search);\nconst experimentsParam = urlParams.get('experiments');\n(experimentsParam?.split(',') || []).forEach((experiment) => {\n openExperiments.push(experiment);\n});\n\nexport default {\n title: 'Video',\n component: Video,\n argTypes,\n} as Meta;\n\ntype StoryArgs = {\n qualityPolicy: QualityPolicy;\n uri: string;\n containerHeight: number;\n containerWidth: number;\n loop: boolean;\n muted: boolean;\n autoplay: boolean;\n playbackRate: number;\n posterEffect: 'fade';\n focalPointX: number;\n focalPointY: number;\n};\n\nexport const Default: React.VFC<StoryArgs> = (args) => {\n const id = 'comp_12345';\n const videoRef = React.useRef<HTMLVideoElement>(null);\n\n React.useEffect(() => {\n if (videoRef.current) {\n videoRef.current.load();\n }\n }, [args.autoplay, args.qualityPolicy]);\n\n const videoProps: VideoProps = {\n loop: Boolean(args.loop),\n muted: Boolean(args.muted),\n playbackRate: args.playbackRate,\n posterEffect: args.posterEffect,\n autoplay: Boolean(args.autoplay),\n videoMedia: sampleVideo.videoMedia,\n id,\n videoRef,\n qualityPolicy: args.qualityPolicy,\n focalPoint: { x: args.focalPointX, y: args.focalPointY },\n onError: (error) => {\n console.log('Video error:', error);\n },\n };\n\n return (\n <Container width={args.containerWidth} height={args.containerHeight}>\n <Video {...videoProps} />\n </Container>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAyD,IAAAI,YAAA;AAGzD,MAAMC,eAAyB,GAAG,EAAE;AAEpC,MAAMC,SAAS,GAAG,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;AAC7D,MAAMC,gBAAgB,GAAGL,SAAS,CAACM,GAAG,CAAC,aAAa,CAAC;AACrD,CAAC,CAAAD,gBAAgB,oBAAhBA,gBAAgB,CAAEE,KAAK,CAAC,GAAG,CAAC,KAAI,EAAE,EAAEC,OAAO,CAAEC,UAAU,IAAK;EAC3DV,eAAe,CAACW,IAAI,CAACD,UAAU,CAAC;AAClC,CAAC,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEY;EACbC,KAAK,EAAE,OAAO;EACdC,SA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YAAA;IAAA;EAAA,gBAClEhE,MAAA,CAAAqB,OAAA,CAAAiC,aAAA,CAACnD,MAAA,CAAAqB,KAAK,MAAAyC,SAAA,CAAA5C,OAAA,MAAKgB,UAAU;IAAAuB,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAAxD,YAAA;MAAAyD,UAAA;MAAAC,YAAA;IAAA;EAAA,EAAG,CACf,CAAC;AAEhB,CAAC;AAAC5C,OAAA,CAAAM,OAAA,GAAAA,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_index","_Container","_args","_jsxFileName","openExperiments","urlParams","URLSearchParams","window","location","search","experimentsParam","get","split","forEach","experiment","push","_default","exports","default","title","component","Video","argTypes","Default","args","id","videoRef","React","useRef","useEffect","current","load","autoplay","qualityPolicy","videoProps","loop","Boolean","muted","playbackRate","posterEffect","videoMedia","sampleVideo","focalPoint","x","focalPointX","y","focalPointY","onError","error","console","log","createElement","Container","width","containerWidth","height","containerHeight","fullscreen","__self","__source","fileName","lineNumber","columnNumber","_extends2"],"sources":["../../src/Video.stories.tsx"],"sourcesContent":["import React from 'react';\nimport { Meta } from '@wix/yoshi-storybook-dependencies';\nimport { Video } from './index';\nimport { Container } from './storybook/Container';\nimport { argTypes, sampleVideo } from './storybook/args';\nimport type { QualityPolicy, VideoProps } from './types';\n\nconst openExperiments: string[] = [];\n\nconst urlParams = new URLSearchParams(window.location.search);\nconst experimentsParam = urlParams.get('experiments');\n(experimentsParam?.split(',') || []).forEach((experiment) => {\n openExperiments.push(experiment);\n});\n\nexport default {\n title: 'Video',\n component: Video,\n argTypes,\n} as Meta;\n\ntype StoryArgs = {\n fullscreen: boolean;\n qualityPolicy: QualityPolicy;\n uri: string;\n containerHeight: number;\n containerWidth: number;\n loop: boolean;\n muted: boolean;\n autoplay: boolean;\n playbackRate: number;\n posterEffect: 'fade';\n focalPointX: number;\n focalPointY: number;\n};\n\nexport const Default: React.VFC<StoryArgs> = (args) => {\n const id = 'comp_12345';\n const videoRef = React.useRef<HTMLVideoElement>(null);\n\n React.useEffect(() => {\n if (videoRef.current) {\n videoRef.current.load();\n }\n }, [args.autoplay, args.qualityPolicy]);\n\n const videoProps: VideoProps = {\n loop: Boolean(args.loop),\n muted: Boolean(args.muted),\n playbackRate: args.playbackRate,\n posterEffect: args.posterEffect,\n autoplay: Boolean(args.autoplay),\n videoMedia: sampleVideo.videoMedia,\n id,\n videoRef,\n qualityPolicy: args.qualityPolicy,\n focalPoint: { x: args.focalPointX, y: args.focalPointY },\n onError: (error) => {\n console.log('Video error:', error);\n },\n };\n\n return (\n <Container\n width={args.containerWidth}\n height={args.containerHeight}\n fullscreen={args.fullscreen}\n >\n <Video {...videoProps} />\n </Container>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAyD,IAAAI,YAAA;AAGzD,MAAMC,eAAyB,GAAG,EAAE;AAEpC,MAAMC,SAAS,GAAG,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;AAC7D,MAAMC,gBAAgB,GAAGL,SAAS,CAACM,GAAG,CAAC,aAAa,CAAC;AACrD,CAAC,CAAAD,gBAAgB,oBAAhBA,gBAAgB,CAAEE,KAAK,CAAC,GAAG,CAAC,KAAI,EAAE,EAAEC,OAAO,CAAEC,UAAU,IAAK;EAC3DV,eAAe,CAACW,IAAI,CAACD,UAAU,CAAC;AAClC,CAAC,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEY;EACbC,KAAK,EAAE,OAAO;EACdC,SAAS,EAAEC,YAAK;EAChBC,QAAQ,EAARA;AACF,CAAC;AAiBM,MAAMC,OAA6B,GAAIC,IAAI,IAAK;EACrD,MAAMC,EAAE,GAAG,YAAY;EACvB,MAAMC,QAAQ,GAAGC,c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,CAAA7C,OAAA,MAAKgB,UAAU;IAAAwB,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAAzD,YAAA;MAAA0D,UAAA;MAAAC,YAAA;IAAA;EAAA,EAAG,CACf,CAAC;AAEhB,CAAC;AAAC7C,OAAA,CAAAM,OAAA,GAAAA,OAAA","ignoreList":[]}
@@ -37,6 +37,13 @@ function getVideoDimension(videoScale, videoWidth, videoHeight) {
37
37
  };
38
38
  }
39
39
  function setVideoFocalPoint(videoNode, focalPoint) {
40
+ const computedStyle = getComputedStyle(videoNode);
41
+ const videoFit = computedStyle.getPropertyValue('--video-fit');
42
+ if (videoFit === 'contain') {
43
+ videoNode.style.setProperty('object-position', 'center');
44
+ return;
45
+ }
46
+ videoNode.style.removeProperty('object-position');
40
47
  const focalX = (focalPoint == null ? void 0 : focalPoint.x) ?? 50;
41
48
  const focalY = (focalPoint == null ? void 0 : focalPoint.y) ?? 50;
42
49
  videoNode.style.setProperty('--focal-x', focalX.toString());
@@ -1 +1 @@
1
- {"version":3,"names":["STATIC_VIDEO_URL","STATIC_ADAPTIVE_VIDEO_URL","isAbsoluteUrl","url","startsWith","sortQualities","sources","sort","a","b","width","height","getCompleteUrl","staticVideoUrl","completeUrl","URL","href","getVideoQualityBySize","targetQuality","find","value","length","getScaleFactor","containerWidth","containerHeight","videoWidth","videoHeight","wScale","hScale","getVideoDimension","videoScale","scale","Math","min","round","setVideoFocalPoint","videoNode","focalPoint","focalX","x","focalY","y","style","setProperty","toString","getVideoSource","uri","qualityPolicy","adaptiveSources","duration","onError","hasProgressiveSources","hasAbsoluteUri","shouldSkipAdaptiveShortVideo","hlsSource","s","format","Hls","Promise","resolve","then","_interopRequireWildcard","require","default","isSupported","videoSourceUrl","patchVideoSource","hls","loadSource","attachMedia","on","Events","ERROR","_","data","fatal","type","ErrorTypes","NETWORK_ERROR","startLoad","Error","details","MEDIA_ERROR","recoverMediaError","destroy","highestQuality","_highestQuality$types","types","src","load","_targetQuality$types$","parseInt","scaleFactor","videoScaledDimensions"],"sources":["../../../src/custom-element/utils.ts"],"sourcesContent":["import { AdaptiveVideoSource, QualityPolicy, VideoSource } from '../types';\n\nconst STATIC_VIDEO_URL = 'https://video.wixstatic.com/';\nconst STATIC_ADAPTIVE_VIDEO_URL = 'https://files.wix.com/';\n\nconst isAbsoluteUrl = (url: string) =>\n url.startsWith('http://') || url.startsWith('https://');\n\nexport function sortQualities(sources: VideoSource[]) {\n return sources.sort((a, b) => a.width * a.height - b.width * b.height);\n}\n\nfunction getCompleteUrl(url: string, staticVideoUrl?: string): string {\n const completeUrl = isAbsoluteUrl(url)\n ? new URL(url)\n : new URL(url, staticVideoUrl);\n return completeUrl.href;\n}\n\nfunction getVideoQualityBySize(\n sources: VideoSource[],\n { width, height }: { width: number; height: number },\n): VideoSource {\n const targetQuality = sources.find(\n (value) => value.width * value.height > width * height,\n );\n\n return targetQuality || sources[sources.length - 1];\n}\n\nfunction getScaleFactor(\n containerWidth: number,\n containerHeight: number,\n videoWidth: number,\n videoHeight: number,\n): { wScale: number; hScale: number } {\n return {\n wScale: containerWidth / videoWidth,\n hScale: containerHeight / videoHeight,\n };\n}\n\nfunction getVideoDimension(\n videoScale: { wScale: number; hScale: number },\n videoWidth: number,\n videoHeight: number,\n): { width: number; height: number } {\n const scale: number = Math.min(videoScale.wScale, videoScale.hScale);\n\n return {\n width: Math.round(videoWidth * scale),\n height: Math.round(videoHeight * scale),\n };\n}\n\nexport function setVideoFocalPoint(\n videoNode: HTMLVideoElement,\n focalPoint: { x: number; y: number },\n) {\n const focalX = focalPoint?.x ?? 50;\n const focalY = focalPoint?.y ?? 50;\n videoNode.style.setProperty('--focal-x', focalX.toString());\n videoNode.style.setProperty('--focal-y', focalY.toString());\n}\n\nexport async function getVideoSource(\n width: number,\n height: number,\n uri: string,\n qualityPolicy: QualityPolicy,\n sources?: VideoSource[],\n adaptiveSources?: AdaptiveVideoSource[],\n duration?: number,\n onError?: (error: Error) => void,\n): Promise<{\n videoSourceUrl: string;\n patchVideoSource: (videoNode: HTMLVideoElement) => void;\n}> {\n const hasProgressiveSources = sources && sources.length > 0;\n const hasAbsoluteUri = uri && isAbsoluteUrl(uri);\n const shouldSkipAdaptiveShortVideo = duration && duration < 40;\n\n if (\n qualityPolicy === 'adaptive' &&\n adaptiveSources &&\n adaptiveSources.length > 0 &&\n !shouldSkipAdaptiveShortVideo\n ) {\n const hlsSource = adaptiveSources.find((s) => s.format === 'hls');\n const Hls = await import('hls.js');\n if (hlsSource && Hls && Hls.default.isSupported()) {\n const videoSourceUrl = getCompleteUrl(\n hlsSource.uri,\n STATIC_ADAPTIVE_VIDEO_URL,\n );\n const patchVideoSource = (videoNode: HTMLVideoElement) => {\n const hls = new Hls.default();\n hls.loadSource(videoSourceUrl);\n hls.attachMedia(videoNode);\n\n hls.on(Hls.default.Events.ERROR, (_, data) => {\n if (data.fatal) {\n switch (data.type) {\n case Hls.default.ErrorTypes.NETWORK_ERROR:\n hls.startLoad();\n if (onError) {\n onError(\n new Error(\n `HLS Network Error: ${data.details}.\\nAttempting to reconnect...`,\n ),\n );\n }\n break;\n case Hls.default.ErrorTypes.MEDIA_ERROR:\n hls.recoverMediaError();\n if (onError) {\n onError(\n new Error(\n `HLS Media Error: ${data.details}.\\nAttempting to recover...`,\n ),\n );\n }\n break;\n default:\n hls.destroy();\n if (onError) {\n onError(\n new Error(\n `HLS Unknown Error: ${data.details}.\\nUnrecoverable playback error`,\n ),\n );\n }\n break;\n }\n }\n });\n };\n return { videoSourceUrl, patchVideoSource };\n }\n }\n if (hasProgressiveSources) {\n const highestQuality = sources[sources.length - 1];\n if (qualityPolicy === 'highest') {\n const url = highestQuality.types.find(\n (type) => type.format === 'mp4',\n )?.uri;\n if (url) {\n const videoSourceUrl = getCompleteUrl(url, STATIC_VIDEO_URL);\n return {\n videoSourceUrl,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = videoSourceUrl;\n videoNode.load();\n },\n };\n }\n } else {\n const videoWidth = parseInt(highestQuality.width.toString(), 10);\n const videoHeight = parseInt(highestQuality.height.toString(), 10);\n const scaleFactor = getScaleFactor(\n width,\n height,\n videoWidth,\n videoHeight,\n );\n const videoScaledDimensions = getVideoDimension(\n scaleFactor,\n videoWidth,\n videoHeight,\n );\n const targetQuality = getVideoQualityBySize(\n sources,\n videoScaledDimensions,\n );\n const url = targetQuality.types.find(\n (type) => type.format === 'mp4',\n )?.uri;\n if (url) {\n const videoSourceUrl = getCompleteUrl(url, STATIC_VIDEO_URL);\n return {\n videoSourceUrl,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = videoSourceUrl;\n videoNode.load();\n },\n };\n }\n }\n }\n if (hasAbsoluteUri) {\n return {\n videoSourceUrl: uri,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = uri;\n videoNode.load();\n },\n };\n }\n return {\n videoSourceUrl: '',\n patchVideoSource: () => {},\n };\n}\n"],"mappings":";;;;;;;;AAEA,MAAMA,gBAAgB,GAAG,8BAA8B;AACvD,MAAMC,yBAAyB,GAAG,wBAAwB;AAE1D,MAAMC,aAAa,GAAIC,GAAW,IAChCA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAElD,SAASC,aAAaA,CAACC,OAAsB,EAAE;EACpD,OAAOA,OAAO,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,KAAK,GAAGF,CAAC,CAACG,MAAM,GAAGF,CAAC,CAACC,KAAK,GAAGD,CAAC,CAACE,MAAM,CAAC;AACxE;AAEA,SAASC,cAAcA,CAACT,GAAW,EAAEU,cAAuB,EAAU;EACpE,MAAMC,WAAW,GAAGZ,aAAa,CAACC,GAAG,CAAC,GAClC,IAAIY,GAAG,CAACZ,GAAG,CAAC,GACZ,IAAIY,GAAG,CAACZ,GAAG,EAAEU,cAAc,CAAC;EAChC,OAAOC,WAAW,CAACE,IAAI;AACzB;AAEA,SA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EA,CAAA,KAAM,CAAC;EAC3B,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["STATIC_VIDEO_URL","STATIC_ADAPTIVE_VIDEO_URL","isAbsoluteUrl","url","startsWith","sortQualities","sources","sort","a","b","width","height","getCompleteUrl","staticVideoUrl","completeUrl","URL","href","getVideoQualityBySize","targetQuality","find","value","length","getScaleFactor","containerWidth","containerHeight","videoWidth","videoHeight","wScale","hScale","getVideoDimension","videoScale","scale","Math","min","round","setVideoFocalPoint","videoNode","focalPoint","computedStyle","getComputedStyle","videoFit","getPropertyValue","style","setProperty","removeProperty","focalX","x","focalY","y","toString","getVideoSource","uri","qualityPolicy","adaptiveSources","duration","onError","hasProgressiveSources","hasAbsoluteUri","shouldSkipAdaptiveShortVideo","hlsSource","s","format","Hls","Promise","resolve","then","_interopRequireWildcard","require","default","isSupported","videoSourceUrl","patchVideoSource","hls","loadSource","attachMedia","on","Events","ERROR","_","data","fatal","type","ErrorTypes","NETWORK_ERROR","startLoad","Error","details","MEDIA_ERROR","recoverMediaError","destroy","highestQuality","_highestQuality$types","types","src","load","_targetQuality$types$","parseInt","scaleFactor","videoScaledDimensions"],"sources":["../../../src/custom-element/utils.ts"],"sourcesContent":["import { AdaptiveVideoSource, QualityPolicy, VideoSource } from '../types';\n\nconst STATIC_VIDEO_URL = 'https://video.wixstatic.com/';\nconst STATIC_ADAPTIVE_VIDEO_URL = 'https://files.wix.com/';\n\nconst isAbsoluteUrl = (url: string) =>\n url.startsWith('http://') || url.startsWith('https://');\n\nexport function sortQualities(sources: VideoSource[]) {\n return sources.sort((a, b) => a.width * a.height - b.width * b.height);\n}\n\nfunction getCompleteUrl(url: string, staticVideoUrl?: string): string {\n const completeUrl = isAbsoluteUrl(url)\n ? new URL(url)\n : new URL(url, staticVideoUrl);\n return completeUrl.href;\n}\n\nfunction getVideoQualityBySize(\n sources: VideoSource[],\n { width, height }: { width: number; height: number },\n): VideoSource {\n const targetQuality = sources.find(\n (value) => value.width * value.height > width * height,\n );\n\n return targetQuality || sources[sources.length - 1];\n}\n\nfunction getScaleFactor(\n containerWidth: number,\n containerHeight: number,\n videoWidth: number,\n videoHeight: number,\n): { wScale: number; hScale: number } {\n return {\n wScale: containerWidth / videoWidth,\n hScale: containerHeight / videoHeight,\n };\n}\n\nfunction getVideoDimension(\n videoScale: { wScale: number; hScale: number },\n videoWidth: number,\n videoHeight: number,\n): { width: number; height: number } {\n const scale: number = Math.min(videoScale.wScale, videoScale.hScale);\n\n return {\n width: Math.round(videoWidth * scale),\n height: Math.round(videoHeight * scale),\n };\n}\n\nexport function setVideoFocalPoint(\n videoNode: HTMLVideoElement,\n focalPoint: { x: number; y: number },\n) {\n const computedStyle = getComputedStyle(videoNode);\n const videoFit = computedStyle.getPropertyValue('--video-fit');\n\n if (videoFit === 'contain') {\n videoNode.style.setProperty('object-position', 'center');\n return;\n }\n\n videoNode.style.removeProperty('object-position');\n const focalX = focalPoint?.x ?? 50;\n const focalY = focalPoint?.y ?? 50;\n videoNode.style.setProperty('--focal-x', focalX.toString());\n videoNode.style.setProperty('--focal-y', focalY.toString());\n}\n\nexport async function getVideoSource(\n width: number,\n height: number,\n uri: string,\n qualityPolicy: QualityPolicy,\n sources?: VideoSource[],\n adaptiveSources?: AdaptiveVideoSource[],\n duration?: number,\n onError?: (error: Error) => void,\n): Promise<{\n videoSourceUrl: string;\n patchVideoSource: (videoNode: HTMLVideoElement) => void;\n}> {\n const hasProgressiveSources = sources && sources.length > 0;\n const hasAbsoluteUri = uri && isAbsoluteUrl(uri);\n const shouldSkipAdaptiveShortVideo = duration && duration < 40;\n\n if (\n qualityPolicy === 'adaptive' &&\n adaptiveSources &&\n adaptiveSources.length > 0 &&\n !shouldSkipAdaptiveShortVideo\n ) {\n const hlsSource = adaptiveSources.find((s) => s.format === 'hls');\n const Hls = await import('hls.js');\n if (hlsSource && Hls && Hls.default.isSupported()) {\n const videoSourceUrl = getCompleteUrl(\n hlsSource.uri,\n STATIC_ADAPTIVE_VIDEO_URL,\n );\n const patchVideoSource = (videoNode: HTMLVideoElement) => {\n const hls = new Hls.default();\n hls.loadSource(videoSourceUrl);\n hls.attachMedia(videoNode);\n\n hls.on(Hls.default.Events.ERROR, (_, data) => {\n if (data.fatal) {\n switch (data.type) {\n case Hls.default.ErrorTypes.NETWORK_ERROR:\n hls.startLoad();\n if (onError) {\n onError(\n new Error(\n `HLS Network Error: ${data.details}.\\nAttempting to reconnect...`,\n ),\n );\n }\n break;\n case Hls.default.ErrorTypes.MEDIA_ERROR:\n hls.recoverMediaError();\n if (onError) {\n onError(\n new Error(\n `HLS Media Error: ${data.details}.\\nAttempting to recover...`,\n ),\n );\n }\n break;\n default:\n hls.destroy();\n if (onError) {\n onError(\n new Error(\n `HLS Unknown Error: ${data.details}.\\nUnrecoverable playback error`,\n ),\n );\n }\n break;\n }\n }\n });\n };\n return { videoSourceUrl, patchVideoSource };\n }\n }\n if (hasProgressiveSources) {\n const highestQuality = sources[sources.length - 1];\n if (qualityPolicy === 'highest') {\n const url = highestQuality.types.find(\n (type) => type.format === 'mp4',\n )?.uri;\n if (url) {\n const videoSourceUrl = getCompleteUrl(url, STATIC_VIDEO_URL);\n return {\n videoSourceUrl,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = videoSourceUrl;\n videoNode.load();\n },\n };\n }\n } else {\n const videoWidth = parseInt(highestQuality.width.toString(), 10);\n const videoHeight = parseInt(highestQuality.height.toString(), 10);\n const scaleFactor = getScaleFactor(\n width,\n height,\n videoWidth,\n videoHeight,\n );\n const videoScaledDimensions = getVideoDimension(\n scaleFactor,\n videoWidth,\n videoHeight,\n );\n const targetQuality = getVideoQualityBySize(\n sources,\n videoScaledDimensions,\n );\n const url = targetQuality.types.find(\n (type) => type.format === 'mp4',\n )?.uri;\n if (url) {\n const videoSourceUrl = getCompleteUrl(url, STATIC_VIDEO_URL);\n return {\n videoSourceUrl,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = videoSourceUrl;\n videoNode.load();\n },\n };\n }\n }\n }\n if (hasAbsoluteUri) {\n return {\n videoSourceUrl: uri,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = uri;\n videoNode.load();\n },\n };\n }\n return {\n videoSourceUrl: '',\n patchVideoSource: () => {},\n };\n}\n"],"mappings":";;;;;;;;AAEA,MAAMA,gBAAgB,GAAG,8BAA8B;AACvD,MAAMC,yBAAyB,GAAG,wBAAwB;AAE1D,MAAMC,aAAa,GAAIC,GAAW,IAChCA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAElD,SAASC,aAAaA,CAACC,OAAsB,EAAE;EACpD,OAAOA,OAAO,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,KAAK,GAAGF,CAAC,CAACG,MAAM,GAAGF,CAAC,CAACC,KAAK,GAAGD,CAAC,CAACE,MAAM,CAAC;AACxE;AAEA,SAASC,cAAcA,CAACT,GAAW,EAAEU,cAAuB,EAAU;EACpE,MAAMC,WAAW,GAAGZ,aAAa,CAACC,GAAG,CAAC,GAClC,IAAIY,GAAG,CAACZ,GAAG,CAAC,GACZ,IAAIY,GAAG,CAACZ,GAAG,EAAEU,cAAc,CAAC;EAChC,OAAOC,WAAW,CAACE,IAAI;AACzB;AAEA,SAASC,qBAAqBA,CAC5BX,OAAsB,EACtB;EAAEI,KAAK;EAAEC;AAA0C,CAAC,EACvC;EACb,MAAMO,aAAa,GAAGZ,OAAO,CAACa,IAAI,CAC/BC,KAAK,IAAKA,KAAK,CAACV,KAAK,GAAGU,KAAK,CAACT,MAAM,GAAGD,KAAK,GAAGC,MAClD,CAAC;EAED,OAAOO,aAAa,IAAIZ,OAAO,CAACA,OAAO,CAACe,MAAM,GAAG,CAAC,CAAC;AACrD;AAEA,SAASC,cAAcA,CACrBC,cAAsB,EACtBC,eAAuB,EACvBC,UAAkB,EAClBC,WAAmB,EACiB;EACpC,OAA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
  width,
11
11
  height,
12
+ fullscreen,
12
13
  children
13
14
  }) => {
15
+ const containerStyle = fullscreen ? {
16
+ position: 'fixed',
17
+ inset: 0,
18
+ backgroundColor: '#000'
19
+ } : {
20
+ width,
21
+ height,
22
+ border: '1px solid red'
23
+ };
24
+ const videoContainerStyle = fullscreen ? {
25
+ width: '100%',
26
+ height: '100%',
27
+ // @ts-expect-error CSS variable
28
+ '--video-fit': 'contain',
29
+ '--video-position': 'center'
30
+ } : {
31
+ width: '100%',
32
+ height: '100%'
33
+ };
14
34
  return /*#__PURE__*/_react.default.createElement("div", {
15
35
  id: id,
16
- style: {
17
- width,
18
- height,
19
- border: '1px solid red'
20
- },
36
+ style: containerStyle,
21
37
  __self: void 0,
22
38
  __source: {
23
39
  fileName: _jsxFileName,
24
- lineNumber: 12,
40
+ lineNumber: 40,
25
41
  columnNumber: 5
26
42
  }
43
+ }, /*#__PURE__*/_react.default.createElement("div", {
44
+ style: videoContainerStyle,
45
+ __self: void 0,
46
+ __source: {
47
+ fileName: _jsxFileName,
48
+ lineNumber: 41,
49
+ columnNumber: 7
50
+ }
27
51
  }, /*#__PURE__*/_react.default.cloneElement(children, {
28
- containerWidth: width,
29
- containerHeight: height
30
- }));
52
+ containerWidth: fullscreen ? window.innerWidth : width,
53
+ containerHeight: fullscreen ? window.innerHeight : height
54
+ })));
31
55
  };
32
56
  exports.Container = Container;
33
57
  //# sourceMappingURL=Container.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_jsxFileName","Container","id","width","height","children","default","createElement","style","border","__self","__source","fileName","lineNumber","columnNumber","React","cloneElement","containerWidth","containerHeight","exports"],"sources":["../../../src/storybook/Container.tsx"],"sourcesContent":["import React from 'react';\n\ntype ContainerProps = React.HTMLProps<{}>;\n\nexport const Container: React.VFC<ContainerProps> = ({\n id,\n width,\n height,\n children,\n}) => {\n return (\n <div id={id} style={{ width, height, border: '1px solid red' }}>\n {React.cloneElement(children as React.ReactElement<any>, {\n containerWidth: width,\n containerHeight: height,\n })}\n </div>\n );\n};\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,IAAAC,YAAA;AAInB,MAAMC,SAAoC,GAAGA,CAAC;EACnDC,EAAE;EACFC,KAAK;EACLC,MAAM;EACNC;AACF,CAAC,KAAK;EACJ,oBACER,MAAA,CAAAS,OAAA,CAAAC,aAAA;IAAKL,EAAE,EAAEA,EAAG;IAACM,KAAK,EAAE;MAAEL,KAAK;MAAEC,MAAM;MAAEK,MAAM,EAAE;IAAgB,CAAE;IAAAC,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAAZ,YAAA;MAAAa,UAAA;MAAAC,YAAA;IAAA;EAAA,gBAC5DC,cAAK,CAACC,YAAY,CAACX,QAAQ,EAA6B;IACvDY,cAAc,EAAEd,KAAK;IACrBe,eAAe,EAAEd;EACnB,CAAC,CACE,CAAC;AAEV,CAAC;AAACe,OAAA,CAAAlB,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_jsxFileName","Container","id","width","height","fullscreen","children","containerStyle","position","inset","backgroundColor","border","videoContainerStyle","default","createElement","style","__self","__source","fileName","lineNumber","columnNumber","React","cloneElement","containerWidth","window","innerWidth","containerHeight","innerHeight","exports"],"sources":["../../../src/storybook/Container.tsx"],"sourcesContent":["import React from 'react';\n\ntype ContainerProps = React.HTMLProps<HTMLDivElement> & {\n fullscreen?: boolean;\n};\n\nexport const Container: React.VFC<ContainerProps> = ({\n id,\n width,\n height,\n fullscreen,\n children,\n}) => {\n const containerStyle: React.CSSProperties = fullscreen\n ? {\n position: 'fixed',\n inset: 0,\n backgroundColor: '#000',\n }\n : {\n width,\n height,\n border: '1px solid red',\n };\n\n const videoContainerStyle: React.CSSProperties = fullscreen\n ? {\n width: '100%',\n height: '100%',\n // @ts-expect-error CSS variable\n '--video-fit': 'contain',\n '--video-position': 'center',\n }\n : {\n width: '100%',\n height: '100%',\n };\n\n return (\n <div id={id} style={containerStyle}>\n <div style={videoContainerStyle}>\n {React.cloneElement(children as React.ReactElement<any>, {\n containerWidth: fullscreen ? window.innerWidth : width,\n containerHeight: fullscreen ? window.innerHeight : height,\n })}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,IAAAC,YAAA;AAMnB,MAAMC,SAAoC,GAAGA,CAAC;EACnDC,EAAE;EACFC,KAAK;EACLC,MAAM;EACNC,UAAU;EACVC;AACF,CAAC,KAAK;EACJ,MAAMC,cAAmC,GAAGF,UAAU,GAClD;IACEG,QAAQ,EAAE,OAAO;IACjBC,KAAK,EAAE,CAAC;IACRC,eAAe,EAAE;EACnB,CAAC,GACD;IACEP,KAAK;IACLC,MAAM;IACNO,MAAM,EAAE;EACV,CAAC;EAEL,MAAMC,mBAAwC,GAAGP,UAAU,GACvD;IACEF,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE,MAAM;IACd;IACA,aAAa,EAAE,SAAS;IACxB,kBAAkB,EAAE;EACtB,CAAC,GACD;IACED,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EAEL,oBACEP,MAAA,CAAAgB,OAAA,CAAAC,aAAA;IAAKZ,EAAE,EAAEA,EAAG;IAACa,KAAK,EAAER,cAAe;IAAAS,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAAlB,YAAA;MAAAmB,UAAA;MAAAC,YAAA;IAAA;EAAA,gBACjCvB,MAAA,CAAAgB,OAAA,CAAAC,aAAA;IAAKC,KAAK,EAAEH,mBAAoB;IAAAI,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAAlB,YAAA;MAAAmB,UAAA;MAAAC,YAAA;IAAA;EAAA,gBAC7BC,cAAK,CAACC,YAAY,CAAChB,QAAQ,EAA6B;IACvDiB,cAAc,EAAElB,UAAU,GAAGmB,MAAM,CAACC,UAAU,GAAGtB,KAAK;IACtDuB,eAAe,EAAErB,UAAU,GAAGmB,MAAM,CAACG,WAAW,GAAGvB;EACrD,CAAC,CACE,CACF,CAAC;AAEV,CAAC;AAACwB,OAAA,CAAA3B,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -62,6 +62,16 @@ const sampleVideo = exports.sampleVideo = {
62
62
  qualityPolicy: 'proportional'
63
63
  };
64
64
  const argTypes = exports.argTypes = {
65
+ fullscreen: {
66
+ control: 'boolean',
67
+ defaultValue: false,
68
+ description: 'Toggle fullscreen mode. In fullscreen, the video is centered and contained.',
69
+ table: {
70
+ type: {
71
+ summary: 'boolean'
72
+ }
73
+ }
74
+ },
65
75
  qualityPolicy: {
66
76
  control: 'select',
67
77
  options: ['proportional', 'adaptive', 'highest', 'none'],
@@ -1 +1 @@
1
- {"version":3,"names":["sampleVideo","exports","videoMedia","sources","quality","width","height","types","format","uri","adaptiveSources","hasAudio","fps","duration","poster","id","name","alt","loop","muted","autoplay","posterEffect","playbackRate","qualityPolicy","argTypes","control","options","defaultValue","description","table","type","summary","containerWidth","containerHeight","undefined","focalPointX","min","max","step","focalPointY"],"sources":["../../../src/storybook/args.ts"],"sourcesContent":["export const sampleVideo = {\n videoMedia: {\n sources: [\n {\n quality: '1080p' as const,\n width: 1920,\n height: 1080,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '720p' as const,\n width: 1280,\n height: 720,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '480p' as const,\n width: 854,\n height: 480,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/480p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '360p' as const,\n width: 640,\n height: 360,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/360p/mp4/file.mp4',\n },\n ],\n },\n ],\n adaptiveSources: [\n {\n format: 'hls' as const,\n uri: 'site/media/video/11062b_c1797898279949878ff9bc792dc4a79c/da01a1fc-ad34-44bc-90e8-cc9413c466e6/repackage/hls',\n },\n ],\n uri: 'test-meta-id',\n hasAudio: true,\n fps: 30,\n duration: 40,\n poster: {\n id: 'video-poster',\n uri: '11062b_c1797898279949878ff9bc792dc4a79cf000.jpg',\n width: 1440,\n height: 2560,\n name: 'video-poster.jpg',\n alt: 'alt text',\n },\n },\n loop: true,\n muted: true,\n autoplay: true,\n posterEffect: 'none',\n playbackRate: 1,\n qualityPolicy: 'proportional',\n};\n\nexport const argTypes = {\n qualityPolicy: {\n control: 'select',\n options: ['proportional', 'adaptive', 'highest', 'none'],\n defaultValue: 'proportional',\n description: 'Quality policy for the video',\n table: {\n type: {\n summary: 'enum',\n },\n },\n },\n containerWidth: {\n control: 'number',\n defaultValue: 500,\n description: 'Width in pixels of the container element',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n containerHeight: {\n control: 'number',\n defaultValue: 275,\n description: 'Height in pixels of the container element',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n muted: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should be muted',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n loop: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should loop continuously',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n posterEffect: {\n control: 'select',\n options: [undefined, 'fade'],\n defaultValue: undefined,\n description: 'Effect to apply when transitioning from poster to video',\n table: {\n type: {\n summary: 'string',\n },\n },\n },\n playbackRate: {\n control: 'number',\n defaultValue: 1,\n description: 'The playback rate of the video',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n autoplay: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should autoplay',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n focalPointX: {\n control: {\n type: 'range',\n min: 0,\n max: 100,\n step: 5,\n },\n defaultValue: 50,\n description:\n 'Horizontal focal point for video positioning (0 = left, 100 = right)',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n focalPointY: {\n control: {\n type: 'range',\n min: 0,\n max: 100,\n step: 5,\n },\n defaultValue: 50,\n description:\n 'Vertical focal point for video positioning (0 = top, 100 = bottom)',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n};\n"],"mappings":";;;;AAAO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzBE,UAAU,EAAE;IACVC,OAAO,EAAE,CACP;MACEC,OAAO,EAAE,OAAgB;MACzBC,KAAK,EAAE,IAAI;MACXC,MAAM,EAAE,IAAI;MACZC,KAAK,EAAE,CACL;QACEC,MAAM,EAAE,KAAc;QACtBC,GAAG,EAAE;MACP,CAAC;IAEL,CAAC,EACD;MACEL,OAAO,EAAE,MAAe;MACxBC,KAAK,EAAE,IAAI;MACXC,MAAM,EAAE,GAAG;MACXC,KAAK,EAAE,CACL;QACEC,MAAM,EAAE,KAAc;QACtBC,GAAG,EAAE;MACP,CAAC;IAEL,CAAC,EACD;MACEL,OAAO,EAAE,MAAe;MACxBC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE,GAAG;MACXC,KAAK,EAAE,CACL;QACEC,MAAM,EAAE,KAAc;QACtBC,GAAG,EAAE;MACP,CAAC;IAEL,CAAC,EACD;MACEL,OAAO,EAAE,MAAe;MACxBC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE,GAAG;MACXC,KAAK,EAAE,CACL;QACEC,MAAM,EAAE,KAAc;QACtBC,GAAG,EAAE;MACP,CAAC;IAEL,CAAC,CACF;IACDC,eAAe,EAAE,CACf;MACEF,MAAM,EAAE,KAAc;MACtBC,GAAG,EAAE;IACP,CAAC,CACF;IACDA,GAAG,EAAE,cAAc;IACnBE,QAAQ,EAAE,IAAI;IACdC,GAAG,EAAE,EAAE;IACPC,QAAQ,EAAE,EAAE;IACZC,MAAM,EAAE;MACNC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C,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDV,YAAY,EAAE;IACZI,OAAO,EAAE,QAAQ;IACjBC,OAAO,EAAE,CAACQ,SAAS,EAAE,MAAM,CAAC;IAC5BP,YAAY,EAAEO,SAAS;IACvBN,WAAW,EAAE,yDAAyD;IACtEC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDT,YAAY,EAAE;IACZG,OAAO,EAAE,QAAQ;IACjBE,YAAY,EAAE,CAAC;IACfC,WAAW,EAAE,gCAAgC;IAC7CC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDX,QAAQ,EAAE;IACRK,OAAO,EAAE,SAAS;IAClBE,YAAY,EAAE,IAAI;IAClBC,WAAW,EAAE,mCAAmC;IAChDC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDI,WAAW,EAAE;IACXV,OAAO,EAAE;MACPK,IAAI,EAAE,OAAO;MACbM,GAAG,EAAE,CAAC;MACNC,GAAG,EAAE,GAAG;MACRC,IAAI,EAAE;IACR,CAAC;IACDX,YAAY,EAAE,EAAE;IAChBC,WAAW,EACT,sEAAsE;IACxEC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDQ,WAAW,EAAE;IACXd,OAAO,EAAE;MACPK,IAAI,EAAE,OAAO;MACbM,GAAG,EAAE,CAAC;MACNC,GAAG,EAAE,GAAG;MACRC,IAAI,EAAE;IACR,CAAC;IACDX,YAAY,EAAE,EAAE;IAChBC,WAAW,EACT,oEAAoE;IACtEC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["sampleVideo","exports","videoMedia","sources","quality","width","height","types","format","uri","adaptiveSources","hasAudio","fps","duration","poster","id","name","alt","loop","muted","autoplay","posterEffect","playbackRate","qualityPolicy","argTypes","fullscreen","control","defaultValue","description","table","type","summary","options","containerWidth","containerHeight","undefined","focalPointX","min","max","step","focalPointY"],"sources":["../../../src/storybook/args.ts"],"sourcesContent":["export const sampleVideo = {\n videoMedia: {\n sources: [\n {\n quality: '1080p' as const,\n width: 1920,\n height: 1080,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '720p' as const,\n width: 1280,\n height: 720,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '480p' as const,\n width: 854,\n height: 480,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/480p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '360p' as const,\n width: 640,\n height: 360,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/360p/mp4/file.mp4',\n },\n ],\n },\n ],\n adaptiveSources: [\n {\n format: 'hls' as const,\n uri: 'site/media/video/11062b_c1797898279949878ff9bc792dc4a79c/da01a1fc-ad34-44bc-90e8-cc9413c466e6/repackage/hls',\n },\n ],\n uri: 'test-meta-id',\n hasAudio: true,\n fps: 30,\n duration: 40,\n poster: {\n id: 'video-poster',\n uri: '11062b_c1797898279949878ff9bc792dc4a79cf000.jpg',\n width: 1440,\n height: 2560,\n name: 'video-poster.jpg',\n alt: 'alt text',\n },\n },\n loop: true,\n muted: true,\n autoplay: true,\n posterEffect: 'none',\n playbackRate: 1,\n qualityPolicy: 'proportional',\n};\n\nexport const argTypes = {\n fullscreen: {\n control: 'boolean',\n defaultValue: false,\n description:\n 'Toggle fullscreen mode. In fullscreen, the video is centered and contained.',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n qualityPolicy: {\n control: 'select',\n options: ['proportional', 'adaptive', 'highest', 'none'],\n defaultValue: 'proportional',\n description: 'Quality policy for the video',\n table: {\n type: {\n summary: 'enum',\n },\n },\n },\n containerWidth: {\n control: 'number',\n defaultValue: 500,\n description: 'Width in pixels of the container element',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n containerHeight: {\n control: 'number',\n defaultValue: 275,\n description: 'Height in pixels of the container element',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n muted: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should be muted',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n loop: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should loop continuously',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n posterEffect: {\n control: 'select',\n options: [undefined, 'fade'],\n defaultValue: undefined,\n description: 'Effect to apply when transitioning from poster to video',\n table: {\n type: {\n summary: 'string',\n },\n },\n },\n playbackRate: {\n control: 'number',\n defaultValue: 1,\n description: 'The playback rate of the video',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n autoplay: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should autoplay',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n focalPointX: {\n control: {\n type: 'range',\n min: 0,\n max: 100,\n step: 5,\n },\n defaultValue: 50,\n description:\n 'Horizontal focal point for video positioning (0 = left, 100 = right)',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n focalPointY: {\n control: {\n type: 'range',\n min: 0,\n max: 100,\n step: 5,\n },\n defaultValue: 50,\n description:\n 'Vertical focal point for video positioning (0 = top, 100 = bottom)',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n};\n"],"mappings":";;;;AAAO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzBE,UAAU,EAAE;IACVC,OAAO,EAAE,CACP;MACEC,OAAO,EAAE,OAAgB;MACzBC,KAAK,EAAE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AAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDT,YAAY,EAAE;IACZI,OAAO,EAAE,QAAQ;IACjBC,YAAY,EAAE,CAAC;IACfC,WAAW,EAAE,gCAAgC;IAC7CC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDX,QAAQ,EAAE;IACRM,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,IAAI;IAClBC,WAAW,EAAE,mCAAmC;IAChDC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDK,WAAW,EAAE;IACXV,OAAO,EAAE;MACPI,IAAI,EAAE,OAAO;MACbO,GAAG,EAAE,CAAC;MACNC,GAAG,EAAE,GAAG;MACRC,IAAI,EAAE;IACR,CAAC;IACDZ,YAAY,EAAE,EAAE;IAChBC,WAAW,EACT,sEAAsE;IACxEC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDS,WAAW,EAAE;IACXd,OAAO,EAAE;MACPI,IAAI,EAAE,OAAO;MACbO,GAAG,EAAE,CAAC;MACNC,GAAG,EAAE,GAAG;MACRC,IAAI,EAAE;IACR,CAAC;IACDZ,YAAY,EAAE,EAAE;IAChBC,WAAW,EACT,oEAAoE;IACtEC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF;AACF,CAAC","ignoreList":[]}
@@ -41,7 +41,8 @@ export const Default = args => {
41
41
  };
42
42
  return /*#__PURE__*/React.createElement(Container, {
43
43
  width: args.containerWidth,
44
- height: args.containerHeight
44
+ height: args.containerHeight,
45
+ fullscreen: args.fullscreen
45
46
  }, /*#__PURE__*/React.createElement(Video, videoProps));
46
47
  };
47
48
  //# sourceMappingURL=Video.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","Video","Container","argTypes","sampleVideo","openExperiments","urlParams","URLSearchParams","window","location","search","experimentsParam","get","split","forEach","experiment","push","title","component","Default","args","id","videoRef","useRef","useEffect","current","load","autoplay","qualityPolicy","videoProps","loop","Boolean","muted","playbackRate","posterEffect","videoMedia","focalPoint","x","focalPointX","y","focalPointY","onError","error","console","log","createElement","width","containerWidth","height","containerHeight"],"sources":["../../src/Video.stories.tsx"],"sourcesContent":["import React from 'react';\nimport { Meta } from '@wix/yoshi-storybook-dependencies';\nimport { Video } from './index';\nimport { Container } from './storybook/Container';\nimport { argTypes, sampleVideo } from './storybook/args';\nimport type { QualityPolicy, VideoProps } from './types';\n\nconst openExperiments: string[] = [];\n\nconst urlParams = new URLSearchParams(window.location.search);\nconst experimentsParam = urlParams.get('experiments');\n(experimentsParam?.split(',') || []).forEach((experiment) => {\n openExperiments.push(experiment);\n});\n\nexport default {\n title: 'Video',\n component: Video,\n argTypes,\n} as Meta;\n\ntype StoryArgs = {\n qualityPolicy: QualityPolicy;\n uri: string;\n containerHeight: number;\n containerWidth: number;\n loop: boolean;\n muted: boolean;\n autoplay: boolean;\n playbackRate: number;\n posterEffect: 'fade';\n focalPointX: number;\n focalPointY: number;\n};\n\nexport const Default: React.VFC<StoryArgs> = (args) => {\n const id = 'comp_12345';\n const videoRef = React.useRef<HTMLVideoElement>(null);\n\n React.useEffect(() => {\n if (videoRef.current) {\n videoRef.current.load();\n }\n }, [args.autoplay, args.qualityPolicy]);\n\n const videoProps: VideoProps = {\n loop: Boolean(args.loop),\n muted: Boolean(args.muted),\n playbackRate: args.playbackRate,\n posterEffect: args.posterEffect,\n autoplay: Boolean(args.autoplay),\n videoMedia: sampleVideo.videoMedia,\n id,\n videoRef,\n qualityPolicy: args.qualityPolicy,\n focalPoint: { x: args.focalPointX, y: args.focalPointY },\n onError: (error) => {\n console.log('Video error:', error);\n },\n };\n\n return (\n <Container width={args.containerWidth} height={args.containerHeight}>\n <Video {...videoProps} />\n </Container>\n );\n};\n"],"mappings":"AAAA,OAAOA,KA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AU,EAAE/B,WAAW,CAAC+B,UAAU;IAClCd,EAAE;IACFC,QAAQ;IACRM,aAAa,EAAER,IAAI,CAACQ,aAAa;IACjCQ,UAAU,EAAE;MAAEC,CAAC,EAAEjB,IAAI,CAACkB,WAAW;MAAEC,CAAC,EAAEnB,IAAI,CAACoB;IAAY,CAAC;IACxDC,OAAO,EAAGC,KAAK,IAAK;MAClBC,OAAO,CAACC,GAAG,CAAC,cAAc,EAAEF,KAAK,CAAC;IACpC;EACF,CAAC;EAED,oBACE1C,KAAA,CAAA6C,aAAA,CAAC3C,SAAS;IAAC4C,KAAK,EAAE1B,IAAI,CAAC2B,cAAe;IAACC,MAAM,EAAE5B,IAAI,CAAC6B;EAAgB,gBAClEjD,KAAA,CAAA6C,aAAA,CAAC5C,KAAK,EAAK4B,UAAa,CACf,CAAC;AAEhB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","Video","Container","argTypes","sampleVideo","openExperiments","urlParams","URLSearchParams","window","location","search","experimentsParam","get","split","forEach","experiment","push","title","component","Default","args","id","videoRef","useRef","useEffect","current","load","autoplay","qualityPolicy","videoProps","loop","Boolean","muted","playbackRate","posterEffect","videoMedia","focalPoint","x","focalPointX","y","focalPointY","onError","error","console","log","createElement","width","containerWidth","height","containerHeight","fullscreen"],"sources":["../../src/Video.stories.tsx"],"sourcesContent":["import React from 'react';\nimport { Meta } from '@wix/yoshi-storybook-dependencies';\nimport { Video } from './index';\nimport { Container } from './storybook/Container';\nimport { argTypes, sampleVideo } from './storybook/args';\nimport type { QualityPolicy, VideoProps } from './types';\n\nconst openExperiments: string[] = [];\n\nconst urlParams = new URLSearchParams(window.location.search);\nconst experimentsParam = urlParams.get('experiments');\n(experimentsParam?.split(',') || []).forEach((experiment) => {\n openExperiments.push(experiment);\n});\n\nexport default {\n title: 'Video',\n component: Video,\n argTypes,\n} as Meta;\n\ntype StoryArgs = {\n fullscreen: boolean;\n qualityPolicy: QualityPolicy;\n uri: string;\n containerHeight: number;\n containerWidth: number;\n loop: boolean;\n muted: boolean;\n autoplay: boolean;\n playbackRate: number;\n posterEffect: 'fade';\n focalPointX: number;\n focalPointY: number;\n};\n\nexport const Default: React.VFC<StoryArgs> = (args) => {\n const id = 'comp_12345';\n const videoRef = React.useRef<HTMLVideoElement>(null);\n\n React.useEffect(() => {\n if (videoRef.current) {\n videoRef.current.load();\n }\n }, [args.autoplay, args.qualityPolicy]);\n\n const videoProps: VideoProps = {\n loop: Boolean(args.loop),\n muted: Boolean(args.muted),\n playbackRate: args.playbackRate,\n posterEffect: args.posterEffect,\n autoplay: Boolean(args.autoplay),\n videoMedia: sampleVideo.videoMedia,\n id,\n videoRef,\n qualityPolicy: args.qualityPolicy,\n focalPoint: { x: args.focalPointX, y: args.focalPointY },\n onError: (error) => {\n console.log('Video error:', error);\n },\n };\n\n return (\n <Container\n width={args.containerWidth}\n height={args.containerHeight}\n fullscreen={args.fullscreen}\n >\n <Video {...videoProps} />\n </Container>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,KAAK,QAAQ,SAAS;AAC/B,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,QAAQ,EAAEC,WAAW,QAAQ,kBAAkB;AAGxD,MAAMC,eAAyB,GAAG,EAAE;AAEpC,MAAMC,SAAS,GAAG,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;AAC7D,MAAMC,gBAAgB,GAAGL,SAAS,CAACM,GAAG,CAAC,aAAa,CAAC;AACrD,CAAC,CAAAD,gBAAgB,oBAAhBA,gBAAgB,CAAEE,KAAK,CAAC,GAAG,CAAC,KAAI,EAAE,EAAEC,OAAO,CAAEC,UAAU,IAAK;EAC3DV,eAAe,CAACW,IAAI,CAACD,UAAU,CAAC;AAClC,CAAC,CAAC;AAEF,eAAe;EACbE,KAAK,EAAE,OAAO;EACdC,SAAS,EAAEjB,KAAK;EAChBE;AACF,CAAC;AAiBD,OAAO,MAAMgB,OAA6B,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ideoDimension(videoScale, videoWidth, videoHeight) {
30
30
  };
31
31
  }
32
32
  export function setVideoFocalPoint(videoNode, focalPoint) {
33
+ const computedStyle = getComputedStyle(videoNode);
34
+ const videoFit = computedStyle.getPropertyValue('--video-fit');
35
+ if (videoFit === 'contain') {
36
+ videoNode.style.setProperty('object-position', 'center');
37
+ return;
38
+ }
39
+ videoNode.style.removeProperty('object-position');
33
40
  const focalX = (focalPoint == null ? void 0 : focalPoint.x) ?? 50;
34
41
  const focalY = (focalPoint == null ? void 0 : focalPoint.y) ?? 50;
35
42
  videoNode.style.setProperty('--focal-x', focalX.toString());
@@ -1 +1 @@
1
- {"version":3,"names":["STATIC_VIDEO_URL","STATIC_ADAPTIVE_VIDEO_URL","isAbsoluteUrl","url","startsWith","sortQualities","sources","sort","a","b","width","height","getCompleteUrl","staticVideoUrl","completeUrl","URL","href","getVideoQualityBySize","_ref","targetQuality","find","value","length","getScaleFactor","containerWidth","containerHeight","videoWidth","videoHeight","wScale","hScale","getVideoDimension","videoScale","scale","Math","min","round","setVideoFocalPoint","videoNode","focalPoint","focalX","x","focalY","y","style","setProperty","toString","getVideoSource","uri","qualityPolicy","adaptiveSources","duration","onError","hasProgressiveSources","hasAbsoluteUri","shouldSkipAdaptiveShortVideo","hlsSource","s","format","Hls","default","isSupported","videoSourceUrl","patchVideoSource","hls","loadSource","attachMedia","on","Events","ERROR","_","data","fatal","type","ErrorTypes","NETWORK_ERROR","startLoad","Error","details","MEDIA_ERROR","recoverMediaError","destroy","highestQuality","_highestQuality$types","types","src","load","_targetQuality$types$","parseInt","scaleFactor","videoScaledDimensions"],"sources":["../../../src/custom-element/utils.ts"],"sourcesContent":["import { AdaptiveVideoSource, QualityPolicy, VideoSource } from '../types';\n\nconst STATIC_VIDEO_URL = 'https://video.wixstatic.com/';\nconst STATIC_ADAPTIVE_VIDEO_URL = 'https://files.wix.com/';\n\nconst isAbsoluteUrl = (url: string) =>\n url.startsWith('http://') || url.startsWith('https://');\n\nexport function sortQualities(sources: VideoSource[]) {\n return sources.sort((a, b) => a.width * a.height - b.width * b.height);\n}\n\nfunction getCompleteUrl(url: string, staticVideoUrl?: string): string {\n const completeUrl = isAbsoluteUrl(url)\n ? new URL(url)\n : new URL(url, staticVideoUrl);\n return completeUrl.href;\n}\n\nfunction getVideoQualityBySize(\n sources: VideoSource[],\n { width, height }: { width: number; height: number },\n): VideoSource {\n const targetQuality = sources.find(\n (value) => value.width * value.height > width * height,\n );\n\n return targetQuality || sources[sources.length - 1];\n}\n\nfunction getScaleFactor(\n containerWidth: number,\n containerHeight: number,\n videoWidth: number,\n videoHeight: number,\n): { wScale: number; hScale: number } {\n return {\n wScale: containerWidth / videoWidth,\n hScale: containerHeight / videoHeight,\n };\n}\n\nfunction getVideoDimension(\n videoScale: { wScale: number; hScale: number },\n videoWidth: number,\n videoHeight: number,\n): { width: number; height: number } {\n const scale: number = Math.min(videoScale.wScale, videoScale.hScale);\n\n return {\n width: Math.round(videoWidth * scale),\n height: Math.round(videoHeight * scale),\n };\n}\n\nexport function setVideoFocalPoint(\n videoNode: HTMLVideoElement,\n focalPoint: { x: number; y: number },\n) {\n const focalX = focalPoint?.x ?? 50;\n const focalY = focalPoint?.y ?? 50;\n videoNode.style.setProperty('--focal-x', focalX.toString());\n videoNode.style.setProperty('--focal-y', focalY.toString());\n}\n\nexport async function getVideoSource(\n width: number,\n height: number,\n uri: string,\n qualityPolicy: QualityPolicy,\n sources?: VideoSource[],\n adaptiveSources?: AdaptiveVideoSource[],\n duration?: number,\n onError?: (error: Error) => void,\n): Promise<{\n videoSourceUrl: string;\n patchVideoSource: (videoNode: HTMLVideoElement) => void;\n}> {\n const hasProgressiveSources = sources && sources.length > 0;\n const hasAbsoluteUri = uri && isAbsoluteUrl(uri);\n const shouldSkipAdaptiveShortVideo = duration && duration < 40;\n\n if (\n qualityPolicy === 'adaptive' &&\n adaptiveSources &&\n adaptiveSources.length > 0 &&\n !shouldSkipAdaptiveShortVideo\n ) {\n const hlsSource = adaptiveSources.find((s) => s.format === 'hls');\n const Hls = await import('hls.js');\n if (hlsSource && Hls && Hls.default.isSupported()) {\n const videoSourceUrl = getCompleteUrl(\n hlsSource.uri,\n STATIC_ADAPTIVE_VIDEO_URL,\n );\n const patchVideoSource = (videoNode: HTMLVideoElement) => {\n const hls = new Hls.default();\n hls.loadSource(videoSourceUrl);\n hls.attachMedia(videoNode);\n\n hls.on(Hls.default.Events.ERROR, (_, data) => {\n if (data.fatal) {\n switch (data.type) {\n case Hls.default.ErrorTypes.NETWORK_ERROR:\n hls.startLoad();\n if (onError) {\n onError(\n new Error(\n `HLS Network Error: ${data.details}.\\nAttempting to reconnect...`,\n ),\n );\n }\n break;\n case Hls.default.ErrorTypes.MEDIA_ERROR:\n hls.recoverMediaError();\n if (onError) {\n onError(\n new Error(\n `HLS Media Error: ${data.details}.\\nAttempting to recover...`,\n ),\n );\n }\n break;\n default:\n hls.destroy();\n if (onError) {\n onError(\n new Error(\n `HLS Unknown Error: ${data.details}.\\nUnrecoverable playback error`,\n ),\n );\n }\n break;\n }\n }\n });\n };\n return { videoSourceUrl, patchVideoSource };\n }\n }\n if (hasProgressiveSources) {\n const highestQuality = sources[sources.length - 1];\n if (qualityPolicy === 'highest') {\n const url = highestQuality.types.find(\n (type) => type.format === 'mp4',\n )?.uri;\n if (url) {\n const videoSourceUrl = getCompleteUrl(url, STATIC_VIDEO_URL);\n return {\n videoSourceUrl,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = videoSourceUrl;\n videoNode.load();\n },\n };\n }\n } else {\n const videoWidth = parseInt(highestQuality.width.toString(), 10);\n const videoHeight = parseInt(highestQuality.height.toString(), 10);\n const scaleFactor = getScaleFactor(\n width,\n height,\n videoWidth,\n videoHeight,\n );\n const videoScaledDimensions = getVideoDimension(\n scaleFactor,\n videoWidth,\n videoHeight,\n );\n const targetQuality = getVideoQualityBySize(\n sources,\n videoScaledDimensions,\n );\n const url = targetQuality.types.find(\n (type) => type.format === 'mp4',\n )?.uri;\n if (url) {\n const videoSourceUrl = getCompleteUrl(url, STATIC_VIDEO_URL);\n return {\n videoSourceUrl,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = videoSourceUrl;\n videoNode.load();\n },\n };\n }\n }\n }\n if (hasAbsoluteUri) {\n return {\n videoSourceUrl: uri,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = uri;\n videoNode.load();\n },\n };\n }\n return {\n videoSourceUrl: '',\n patchVideoSource: () => {},\n };\n}\n"],"mappings":"AAEA,MAAMA,gBAAgB,GAAG,8BAA8B;AACvD,MAAMC,yBAAyB,GAAG,wBAAwB;AAE1D,MAAMC,aAAa,GAAIC,GAAW,IAChCA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAEzD,OAAO,SAASC,aAAaA,CAACC,OAAsB,EAAE;EACpD,OAAOA,OAAO,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,KAAK,GAAGF,CAAC,CAACG,MAAM,GAAGF,CAAC,CAACC,KAAK,GAAGD,CAAC,CAACE,MAAM,CAAC;AACxE;AAEA,SAASC,cAAcA,CAACT,GAAW,EAAEU,cAAuB,EAAU;EACpE,MAAMC,WAAW,GAAGZ,aAAa,CAACC,GAAG,CAAC,GAClC,IAAIY,GAAG,CAACZ,GAAG,CAAC,GACZ,IAAIY,GAAG,CAACZ,GAAG,EAAEU,cAAc,CAAC;EAChC,OAAOC,WAAW,CAACE,IAAI;AACzB;AAEA,SAASC,qBAAqBA,CAC5BX,OAAsB,EAAAY,IAAA,EAET;EAAA,IADb;IAAER,KAAK;IAAEC;EAA0C,CAAC,GAAAO,IAAA;EAEpD,MAAMC,aAAa,GAAGb,OAAO,CAACc,IAAI,CAC/BC,KAAK,IAAKA,KAAK,CAACX,KAAK,GAAGW,KAAK,CAACV,MAAM,GAAGD,KAAK,GAAGC,MAClD,CAAC;EAED,OA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Q,CAAC,CAAC,EAAE,EAAE,CAAC;MAClE,MAAM2C,WAAW,GAAGjE,cAAc,CAChCb,KAAK,EACLC,MAAM,EACNe,UAAU,EACVC,WACF,CAAC;MACD,MAAM8D,qBAAqB,GAAG3D,iBAAiB,CAC7C0D,WAAW,EACX9D,UAAU,EACVC,WACF,CAAC;MACD,MAAMR,aAAa,GAAGF,qBAAqB,CACzCX,OAAO,EACPmF,qBACF,CAAC;MACD,MAAMtF,GAAG,IAAAmF,qBAAA,GAAGnE,aAAa,CAACgE,KAAK,CAAC/D,IAAI,CACjCoD,IAAI,IAAKA,IAAI,CAACf,MAAM,KAAK,KAC5B,CAAC,qBAFW6B,qBAAA,CAETvC,GAAG;MACN,IAAI5C,GAAG,EAAE;QACP,MAAM0D,cAAc,GAAGjD,cAAc,CAACT,GAAG,EAAEH,gBAAgB,CAAC;QAC5D,OAAO;UACL6D,cAAc;UACdC,gBAAgB,EAAGzB,SAA2B,IAAK;YACjDA,SAAS,CAAC+C,GAAG,GAAGvB,cAAc;YAC9BxB,SAAS,CAACgD,IAAI,CAAC,CAAC;UAClB;QACF,CAAC;MACH;IACF;EACF;EACA,IAAIhC,cAAc,EAAE;IAClB,OAAO;MACLQ,cAAc,EAAEd,GAAG;MACnBe,gBAAgB,EAAGzB,SAA2B,IAAK;QACjDA,SAAS,CAAC+C,GAAG,GAAGrC,GAAG;QACnBV,SAAS,CAACgD,IAAI,CAAC,CAAC;MAClB;IACF,CAAC;EACH;EACA,OAAO;IACLxB,cAAc,EAAE,EAAE;IAClBC,gBAAgB,EAAEA,CAAA,KAAM,CAAC;EAC3B,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["STATIC_VIDEO_URL","STATIC_ADAPTIVE_VIDEO_URL","isAbsoluteUrl","url","startsWith","sortQualities","sources","sort","a","b","width","height","getCompleteUrl","staticVideoUrl","completeUrl","URL","href","getVideoQualityBySize","_ref","targetQuality","find","value","length","getScaleFactor","containerWidth","containerHeight","videoWidth","videoHeight","wScale","hScale","getVideoDimension","videoScale","scale","Math","min","round","setVideoFocalPoint","videoNode","focalPoint","computedStyle","getComputedStyle","videoFit","getPropertyValue","style","setProperty","removeProperty","focalX","x","focalY","y","toString","getVideoSource","uri","qualityPolicy","adaptiveSources","duration","onError","hasProgressiveSources","hasAbsoluteUri","shouldSkipAdaptiveShortVideo","hlsSource","s","format","Hls","default","isSupported","videoSourceUrl","patchVideoSource","hls","loadSource","attachMedia","on","Events","ERROR","_","data","fatal","type","ErrorTypes","NETWORK_ERROR","startLoad","Error","details","MEDIA_ERROR","recoverMediaError","destroy","highestQuality","_highestQuality$types","types","src","load","_targetQuality$types$","parseInt","scaleFactor","videoScaledDimensions"],"sources":["../../../src/custom-element/utils.ts"],"sourcesContent":["import { AdaptiveVideoSource, QualityPolicy, VideoSource } from '../types';\n\nconst STATIC_VIDEO_URL = 'https://video.wixstatic.com/';\nconst STATIC_ADAPTIVE_VIDEO_URL = 'https://files.wix.com/';\n\nconst isAbsoluteUrl = (url: string) =>\n url.startsWith('http://') || url.startsWith('https://');\n\nexport function sortQualities(sources: VideoSource[]) {\n return sources.sort((a, b) => a.width * a.height - b.width * b.height);\n}\n\nfunction getCompleteUrl(url: string, staticVideoUrl?: string): string {\n const completeUrl = isAbsoluteUrl(url)\n ? new URL(url)\n : new URL(url, staticVideoUrl);\n return completeUrl.href;\n}\n\nfunction getVideoQualityBySize(\n sources: VideoSource[],\n { width, height }: { width: number; height: number },\n): VideoSource {\n const targetQuality = sources.find(\n (value) => value.width * value.height > width * height,\n );\n\n return targetQuality || sources[sources.length - 1];\n}\n\nfunction getScaleFactor(\n containerWidth: number,\n containerHeight: number,\n videoWidth: number,\n videoHeight: number,\n): { wScale: number; hScale: number } {\n return {\n wScale: containerWidth / videoWidth,\n hScale: containerHeight / videoHeight,\n };\n}\n\nfunction getVideoDimension(\n videoScale: { wScale: number; hScale: number },\n videoWidth: number,\n videoHeight: number,\n): { width: number; height: number } {\n const scale: number = Math.min(videoScale.wScale, videoScale.hScale);\n\n return {\n width: Math.round(videoWidth * scale),\n height: Math.round(videoHeight * scale),\n };\n}\n\nexport function setVideoFocalPoint(\n videoNode: HTMLVideoElement,\n focalPoint: { x: number; y: number },\n) {\n const computedStyle = getComputedStyle(videoNode);\n const videoFit = computedStyle.getPropertyValue('--video-fit');\n\n if (videoFit === 'contain') {\n videoNode.style.setProperty('object-position', 'center');\n return;\n }\n\n videoNode.style.removeProperty('object-position');\n const focalX = focalPoint?.x ?? 50;\n const focalY = focalPoint?.y ?? 50;\n videoNode.style.setProperty('--focal-x', focalX.toString());\n videoNode.style.setProperty('--focal-y', focalY.toString());\n}\n\nexport async function getVideoSource(\n width: number,\n height: number,\n uri: string,\n qualityPolicy: QualityPolicy,\n sources?: VideoSource[],\n adaptiveSources?: AdaptiveVideoSource[],\n duration?: number,\n onError?: (error: Error) => void,\n): Promise<{\n videoSourceUrl: string;\n patchVideoSource: (videoNode: HTMLVideoElement) => void;\n}> {\n const hasProgressiveSources = sources && sources.length > 0;\n const hasAbsoluteUri = uri && isAbsoluteUrl(uri);\n const shouldSkipAdaptiveShortVideo = duration && duration < 40;\n\n if (\n qualityPolicy === 'adaptive' &&\n adaptiveSources &&\n adaptiveSources.length > 0 &&\n !shouldSkipAdaptiveShortVideo\n ) {\n const hlsSource = adaptiveSources.find((s) => s.format === 'hls');\n const Hls = await import('hls.js');\n if (hlsSource && Hls && Hls.default.isSupported()) {\n const videoSourceUrl = getCompleteUrl(\n hlsSource.uri,\n STATIC_ADAPTIVE_VIDEO_URL,\n );\n const patchVideoSource = (videoNode: HTMLVideoElement) => {\n const hls = new Hls.default();\n hls.loadSource(videoSourceUrl);\n hls.attachMedia(videoNode);\n\n hls.on(Hls.default.Events.ERROR, (_, data) => {\n if (data.fatal) {\n switch (data.type) {\n case Hls.default.ErrorTypes.NETWORK_ERROR:\n hls.startLoad();\n if (onError) {\n onError(\n new Error(\n `HLS Network Error: ${data.details}.\\nAttempting to reconnect...`,\n ),\n );\n }\n break;\n case Hls.default.ErrorTypes.MEDIA_ERROR:\n hls.recoverMediaError();\n if (onError) {\n onError(\n new Error(\n `HLS Media Error: ${data.details}.\\nAttempting to recover...`,\n ),\n );\n }\n break;\n default:\n hls.destroy();\n if (onError) {\n onError(\n new Error(\n `HLS Unknown Error: ${data.details}.\\nUnrecoverable playback error`,\n ),\n );\n }\n break;\n }\n }\n });\n };\n return { videoSourceUrl, patchVideoSource };\n }\n }\n if (hasProgressiveSources) {\n const highestQuality = sources[sources.length - 1];\n if (qualityPolicy === 'highest') {\n const url = highestQuality.types.find(\n (type) => type.format === 'mp4',\n )?.uri;\n if (url) {\n const videoSourceUrl = getCompleteUrl(url, STATIC_VIDEO_URL);\n return {\n videoSourceUrl,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = videoSourceUrl;\n videoNode.load();\n },\n };\n }\n } else {\n const videoWidth = parseInt(highestQuality.width.toString(), 10);\n const videoHeight = parseInt(highestQuality.height.toString(), 10);\n const scaleFactor = getScaleFactor(\n width,\n height,\n videoWidth,\n videoHeight,\n );\n const videoScaledDimensions = getVideoDimension(\n scaleFactor,\n videoWidth,\n videoHeight,\n );\n const targetQuality = getVideoQualityBySize(\n sources,\n videoScaledDimensions,\n );\n const url = targetQuality.types.find(\n (type) => type.format === 'mp4',\n )?.uri;\n if (url) {\n const videoSourceUrl = getCompleteUrl(url, STATIC_VIDEO_URL);\n return {\n videoSourceUrl,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = videoSourceUrl;\n videoNode.load();\n },\n };\n }\n }\n }\n if (hasAbsoluteUri) {\n return {\n videoSourceUrl: uri,\n patchVideoSource: (videoNode: HTMLVideoElement) => {\n videoNode.src = uri;\n videoNode.load();\n },\n };\n }\n return {\n videoSourceUrl: '',\n patchVideoSource: () => {},\n };\n}\n"],"mappings":"AAEA,MAAMA,gBAAgB,GAAG,8BAA8B;AACvD,MAAMC,yBAAyB,GAAG,wBAAwB;AAE1D,MAAMC,aAAa,GAAIC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AMmE,qBAAqB,GAAGhE,iBAAiB,CAC7C+D,WAAW,EACXnE,UAAU,EACVC,WACF,CAAC;MACD,MAAMR,aAAa,GAAGF,qBAAqB,CACzCX,OAAO,EACPwF,qBACF,CAAC;MACD,MAAM3F,GAAG,IAAAwF,qBAAA,GAAGxE,aAAa,CAACqE,KAAK,CAACpE,IAAI,CACjCyD,IAAI,IAAKA,IAAI,CAACf,MAAM,KAAK,KAC5B,CAAC,qBAFW6B,qBAAA,CAETvC,GAAG;MACN,IAAIjD,GAAG,EAAE;QACP,MAAM+D,cAAc,GAAGtD,cAAc,CAACT,GAAG,EAAEH,gBAAgB,CAAC;QAC5D,OAAO;UACLkE,cAAc;UACdC,gBAAgB,EAAG9B,SAA2B,IAAK;YACjDA,SAAS,CAACoD,GAAG,GAAGvB,cAAc;YAC9B7B,SAAS,CAACqD,IAAI,CAAC,CAAC;UAClB;QACF,CAAC;MACH;IACF;EACF;EACA,IAAIhC,cAAc,EAAE;IAClB,OAAO;MACLQ,cAAc,EAAEd,GAAG;MACnBe,gBAAgB,EAAG9B,SAA2B,IAAK;QACjDA,SAAS,CAACoD,GAAG,GAAGrC,GAAG;QACnBf,SAAS,CAACqD,IAAI,CAAC,CAAC;MAClB;IACF,CAAC;EACH;EACA,OAAO;IACLxB,cAAc,EAAE,EAAE;IAClBC,gBAAgB,EAAEA,CAAA,KAAM,CAAC;EAC3B,CAAC;AACH","ignoreList":[]}
@@ -4,18 +4,36 @@ export const Container = _ref => {
4
4
  id,
5
5
  width,
6
6
  height,
7
+ fullscreen,
7
8
  children
8
9
  } = _ref;
10
+ const containerStyle = fullscreen ? {
11
+ position: 'fixed',
12
+ inset: 0,
13
+ backgroundColor: '#000'
14
+ } : {
15
+ width,
16
+ height,
17
+ border: '1px solid red'
18
+ };
19
+ const videoContainerStyle = fullscreen ? {
20
+ width: '100%',
21
+ height: '100%',
22
+ // @ts-expect-error CSS variable
23
+ '--video-fit': 'contain',
24
+ '--video-position': 'center'
25
+ } : {
26
+ width: '100%',
27
+ height: '100%'
28
+ };
9
29
  return /*#__PURE__*/React.createElement("div", {
10
30
  id: id,
11
- style: {
12
- width,
13
- height,
14
- border: '1px solid red'
15
- }
31
+ style: containerStyle
32
+ }, /*#__PURE__*/React.createElement("div", {
33
+ style: videoContainerStyle
16
34
  }, /*#__PURE__*/React.cloneElement(children, {
17
- containerWidth: width,
18
- containerHeight: height
19
- }));
35
+ containerWidth: fullscreen ? window.innerWidth : width,
36
+ containerHeight: fullscreen ? window.innerHeight : height
37
+ })));
20
38
  };
21
39
  //# sourceMappingURL=Container.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","Container","_ref","id","width","height","children","createElement","style","border","cloneElement","containerWidth","containerHeight"],"sources":["../../../src/storybook/Container.tsx"],"sourcesContent":["import React from 'react';\n\ntype ContainerProps = React.HTMLProps<{}>;\n\nexport const Container: React.VFC<ContainerProps> = ({\n id,\n width,\n height,\n children,\n}) => {\n return (\n <div id={id} style={{ width, height, border: '1px solid red' }}>\n {React.cloneElement(children as React.ReactElement<any>, {\n containerWidth: width,\n containerHeight: height,\n })}\n </div>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAIzB,OAAO,MAAMC,SAAoC,GAAGC,IAAA,IAK9C;EAAA,IAL+C;IACnDC,EAAE;IACFC,KAAK;IACLC,MAAM;IACNC;EACF,CAAC,GAAAJ,IAAA;EACC,oBACEF,KAAA,CAAAO,aAAA;IAAKJ,EAAE,EAAEA,EAAG;IAACK,KAAK,EAAE;MAAEJ,KAAK;MAAEC,MAAM;MAAEI,MAAM,EAAE;IAAgB;EAAE,gBAC5DT,KAAK,CAACU,YAAY,CAACJ,QAAQ,EAA6B;IACvDK,cAAc,EAAEP,KAAK;IACrBQ,eAAe,EAAEP;EACnB,CAAC,CACE,CAAC;AAEV,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","Container","_ref","id","width","height","fullscreen","children","containerStyle","position","inset","backgroundColor","border","videoContainerStyle","createElement","style","cloneElement","containerWidth","window","innerWidth","containerHeight","innerHeight"],"sources":["../../../src/storybook/Container.tsx"],"sourcesContent":["import React from 'react';\n\ntype ContainerProps = React.HTMLProps<HTMLDivElement> & {\n fullscreen?: boolean;\n};\n\nexport const Container: React.VFC<ContainerProps> = ({\n id,\n width,\n height,\n fullscreen,\n children,\n}) => {\n const containerStyle: React.CSSProperties = fullscreen\n ? {\n position: 'fixed',\n inset: 0,\n backgroundColor: '#000',\n }\n : {\n width,\n height,\n border: '1px solid red',\n };\n\n const videoContainerStyle: React.CSSProperties = fullscreen\n ? {\n width: '100%',\n height: '100%',\n // @ts-expect-error CSS variable\n '--video-fit': 'contain',\n '--video-position': 'center',\n }\n : {\n width: '100%',\n height: '100%',\n };\n\n return (\n <div id={id} style={containerStyle}>\n <div style={videoContainerStyle}>\n {React.cloneElement(children as React.ReactElement<any>, {\n containerWidth: fullscreen ? window.innerWidth : width,\n containerHeight: fullscreen ? window.innerHeight : height,\n })}\n </div>\n </div>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAMzB,OAAO,MAAMC,SAAoC,GAAGC,IAAA,IAM9C;EAAA,IAN+C;IACnDC,EAAE;IACFC,KAAK;IACLC,MAAM;IACNC,UAAU;IACVC;EACF,CAAC,GAAAL,IAAA;EACC,MAAMM,cAAmC,GAAGF,UAAU,GAClD;IACEG,QAAQ,EAAE,OAAO;IACjBC,KAAK,EAAE,CAAC;IACRC,eAAe,EAAE;EACnB,CAAC,GACD;IACEP,KAAK;IACLC,MAAM;IACNO,MAAM,EAAE;EACV,CAAC;EAEL,MAAMC,mBAAwC,GAAGP,UAAU,GACvD;IACEF,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE,MAAM;IACd;IACA,aAAa,EAAE,SAAS;IACxB,kBAAkB,EAAE;EACtB,CAAC,GACD;IACED,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EAEL,oBACEL,KAAA,CAAAc,aAAA;IAAKX,EAAE,EAAEA,EAAG;IAACY,KAAK,EAAEP;EAAe,gBACjCR,KAAA,CAAAc,aAAA;IAAKC,KAAK,EAAEF;EAAoB,gBAC7Bb,KAAK,CAACgB,YAAY,CAACT,QAAQ,EAA6B;IACvDU,cAAc,EAAEX,UAAU,GAAGY,MAAM,CAACC,UAAU,GAAGf,KAAK;IACtDgB,eAAe,EAAEd,UAAU,GAAGY,MAAM,CAACG,WAAW,GAAGhB;EACrD,CAAC,CACE,CACF,CAAC;AAEV,CAAC","ignoreList":[]}
@@ -58,6 +58,16 @@ export const sampleVideo = {
58
58
  qualityPolicy: 'proportional'
59
59
  };
60
60
  export const argTypes = {
61
+ fullscreen: {
62
+ control: 'boolean',
63
+ defaultValue: false,
64
+ description: 'Toggle fullscreen mode. In fullscreen, the video is centered and contained.',
65
+ table: {
66
+ type: {
67
+ summary: 'boolean'
68
+ }
69
+ }
70
+ },
61
71
  qualityPolicy: {
62
72
  control: 'select',
63
73
  options: ['proportional', 'adaptive', 'highest', 'none'],
@@ -1 +1 @@
1
- {"version":3,"names":["sampleVideo","videoMedia","sources","quality","width","height","types","format","uri","adaptiveSources","hasAudio","fps","duration","poster","id","name","alt","loop","muted","autoplay","posterEffect","playbackRate","qualityPolicy","argTypes","control","options","defaultValue","description","table","type","summary","containerWidth","containerHeight","undefined","focalPointX","min","max","step","focalPointY"],"sources":["../../../src/storybook/args.ts"],"sourcesContent":["export const sampleVideo = {\n videoMedia: {\n sources: [\n {\n quality: '1080p' as const,\n width: 1920,\n height: 1080,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '720p' as const,\n width: 1280,\n height: 720,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '480p' as const,\n width: 854,\n height: 480,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/480p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '360p' as const,\n width: 640,\n height: 360,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/360p/mp4/file.mp4',\n },\n ],\n },\n ],\n adaptiveSources: [\n {\n format: 'hls' as const,\n uri: 'site/media/video/11062b_c1797898279949878ff9bc792dc4a79c/da01a1fc-ad34-44bc-90e8-cc9413c466e6/repackage/hls',\n },\n ],\n uri: 'test-meta-id',\n hasAudio: true,\n fps: 30,\n duration: 40,\n poster: {\n id: 'video-poster',\n uri: '11062b_c1797898279949878ff9bc792dc4a79cf000.jpg',\n width: 1440,\n height: 2560,\n name: 'video-poster.jpg',\n alt: 'alt text',\n },\n },\n loop: true,\n muted: true,\n autoplay: true,\n posterEffect: 'none',\n playbackRate: 1,\n qualityPolicy: 'proportional',\n};\n\nexport const argTypes = {\n qualityPolicy: {\n control: 'select',\n options: ['proportional', 'adaptive', 'highest', 'none'],\n defaultValue: 'proportional',\n description: 'Quality policy for the video',\n table: {\n type: {\n summary: 'enum',\n },\n },\n },\n containerWidth: {\n control: 'number',\n defaultValue: 500,\n description: 'Width in pixels of the container element',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n containerHeight: {\n control: 'number',\n defaultValue: 275,\n description: 'Height in pixels of the container element',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n muted: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should be muted',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n loop: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should loop continuously',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n posterEffect: {\n control: 'select',\n options: [undefined, 'fade'],\n defaultValue: undefined,\n description: 'Effect to apply when transitioning from poster to video',\n table: {\n type: {\n summary: 'string',\n },\n },\n },\n playbackRate: {\n control: 'number',\n defaultValue: 1,\n description: 'The playback rate of the video',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n autoplay: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should autoplay',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n focalPointX: {\n control: {\n type: 'range',\n min: 0,\n max: 100,\n step: 5,\n },\n defaultValue: 50,\n description:\n 'Horizontal focal point for video positioning (0 = left, 100 = right)',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n focalPointY: {\n control: {\n type: 'range',\n min: 0,\n max: 100,\n step: 5,\n },\n defaultValue: 50,\n description:\n 'Vertical focal point for video positioning (0 = top, 100 = bottom)',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n};\n"],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAG;EACzBC,UAAU,EAAE;IACVC,OAAO,EAAE,CACP;MACEC,OAAO,EAAE,OAAgB;MACzBC,KAAK,EAAE,IAAI;MACXC,MAAM,EAAE,IAAI;MACZC,KAAK,EAAE,CACL;QACEC,MAAM,EAAE,KAAc;QACtBC,GAAG,EAAE;MACP,CAAC;IAEL,CAAC,EACD;MACEL,OAAO,EAAE,MAAe;MACxBC,KAAK,EAAE,IAAI;MACXC,MAAM,EAAE,GAAG;MACXC,KAAK,EAAE,CACL;QACEC,MAAM,EAAE,KAAc;QACtBC,GAAG,EAAE;MACP,CAAC;IAEL,CAAC,EACD;MACEL,OAAO,EAAE,MAAe;MACxBC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE,GAAG;MACXC,KAAK,EAAE,CACL;QACEC,MAAM,EAAE,KAAc;QACtBC,GAAG,EAAE;MACP,CAAC;IAEL,CAAC,EACD;MACEL,OAAO,EAAE,MAAe;MACxBC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE,GAAG;MACXC,KAAK,EAAE,CACL;QACEC,MAAM,EAAE,KAAc;QACtBC,GAAG,EAAE;MACP,CAAC;IAEL,CAAC,CACF;IACDC,eAAe,EAAE,CACf;MACEF,MAAM,EAAE,KAAc;MACtBC,GAAG,EAAE;IACP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I,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["sampleVideo","videoMedia","sources","quality","width","height","types","format","uri","adaptiveSources","hasAudio","fps","duration","poster","id","name","alt","loop","muted","autoplay","posterEffect","playbackRate","qualityPolicy","argTypes","fullscreen","control","defaultValue","description","table","type","summary","options","containerWidth","containerHeight","undefined","focalPointX","min","max","step","focalPointY"],"sources":["../../../src/storybook/args.ts"],"sourcesContent":["export const sampleVideo = {\n videoMedia: {\n sources: [\n {\n quality: '1080p' as const,\n width: 1920,\n height: 1080,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '720p' as const,\n width: 1280,\n height: 720,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '480p' as const,\n width: 854,\n height: 480,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/480p/mp4/file.mp4',\n },\n ],\n },\n {\n quality: '360p' as const,\n width: 640,\n height: 360,\n types: [\n {\n format: 'mp4' as const,\n uri: 'video/11062b_c1797898279949878ff9bc792dc4a79c/360p/mp4/file.mp4',\n },\n ],\n },\n ],\n adaptiveSources: [\n {\n format: 'hls' as const,\n uri: 'site/media/video/11062b_c1797898279949878ff9bc792dc4a79c/da01a1fc-ad34-44bc-90e8-cc9413c466e6/repackage/hls',\n },\n ],\n uri: 'test-meta-id',\n hasAudio: true,\n fps: 30,\n duration: 40,\n poster: {\n id: 'video-poster',\n uri: '11062b_c1797898279949878ff9bc792dc4a79cf000.jpg',\n width: 1440,\n height: 2560,\n name: 'video-poster.jpg',\n alt: 'alt text',\n },\n },\n loop: true,\n muted: true,\n autoplay: true,\n posterEffect: 'none',\n playbackRate: 1,\n qualityPolicy: 'proportional',\n};\n\nexport const argTypes = {\n fullscreen: {\n control: 'boolean',\n defaultValue: false,\n description:\n 'Toggle fullscreen mode. In fullscreen, the video is centered and contained.',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n qualityPolicy: {\n control: 'select',\n options: ['proportional', 'adaptive', 'highest', 'none'],\n defaultValue: 'proportional',\n description: 'Quality policy for the video',\n table: {\n type: {\n summary: 'enum',\n },\n },\n },\n containerWidth: {\n control: 'number',\n defaultValue: 500,\n description: 'Width in pixels of the container element',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n containerHeight: {\n control: 'number',\n defaultValue: 275,\n description: 'Height in pixels of the container element',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n muted: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should be muted',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n loop: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should loop continuously',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n posterEffect: {\n control: 'select',\n options: [undefined, 'fade'],\n defaultValue: undefined,\n description: 'Effect to apply when transitioning from poster to video',\n table: {\n type: {\n summary: 'string',\n },\n },\n },\n playbackRate: {\n control: 'number',\n defaultValue: 1,\n description: 'The playback rate of the video',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n autoplay: {\n control: 'boolean',\n defaultValue: true,\n description: 'Whether the video should autoplay',\n table: {\n type: {\n summary: 'boolean',\n },\n },\n },\n focalPointX: {\n control: {\n type: 'range',\n min: 0,\n max: 100,\n step: 5,\n },\n defaultValue: 50,\n description:\n 'Horizontal focal point for video positioning (0 = left, 100 = right)',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n focalPointY: {\n control: {\n type: 'range',\n min: 0,\n max: 100,\n step: 5,\n },\n defaultValue: 50,\n description:\n 'Vertical focal point for video positioning (0 = top, 100 = bottom)',\n table: {\n type: {\n summary: 'number',\n },\n },\n },\n};\n"],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAG;EAC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R,YAAY,EAAEQ,SAAS;IACvBP,WAAW,EAAE,yDAAyD;IACtEC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDT,YAAY,EAAE;IACZI,OAAO,EAAE,QAAQ;IACjBC,YAAY,EAAE,CAAC;IACfC,WAAW,EAAE,gCAAgC;IAC7CC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDX,QAAQ,EAAE;IACRM,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,IAAI;IAClBC,WAAW,EAAE,mCAAmC;IAChDC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDK,WAAW,EAAE;IACXV,OAAO,EAAE;MACPI,IAAI,EAAE,OAAO;MACbO,GAAG,EAAE,CAAC;MACNC,GAAG,EAAE,GAAG;MACRC,IAAI,EAAE;IACR,CAAC;IACDZ,YAAY,EAAE,EAAE;IAChBC,WAAW,EACT,sEAAsE;IACxEC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDS,WAAW,EAAE;IACXd,OAAO,EAAE;MACPI,IAAI,EAAE,OAAO;MACbO,GAAG,EAAE,CAAC;MACNC,GAAG,EAAE,GAAG;MACRC,IAAI,EAAE;IACR,CAAC;IACDZ,YAAY,EAAE,EAAE;IAChBC,WAAW,EACT,oEAAoE;IACtEC,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,OAAO,EAAE;MACX;IACF;EACF;AACF,CAAC","ignoreList":[]}
@@ -361,4 +361,4 @@
361
361
 
362
362
 
363
363
 
364
- window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx))$"}];</script><script src="main.f45a6aa8.iframe.bundle.js"></script></body></html>
364
+ window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx))$"}];</script><script src="main.4e295f79.iframe.bundle.js"></script></body></html>
@@ -15698,7 +15698,7 @@ var update = injectStylesIntoStyleTag_default()(Video_module/* default */.A, opt
15698
15698
 
15699
15699
  /* harmony default export */ const src_Video_module = (Video_module/* default */.A.locals || {});
15700
15700
  ;// ./src/custom-element/utils.ts
15701
- const STATIC_VIDEO_URL='https://video.wixstatic.com/';const STATIC_ADAPTIVE_VIDEO_URL='https://files.wix.com/';const isAbsoluteUrl=url=>url.startsWith('http://')||url.startsWith('https://');function sortQualities(sources){return sources.sort((a,b)=>a.width*a.height-b.width*b.height);}function getCompleteUrl(url,staticVideoUrl){const completeUrl=isAbsoluteUrl(url)?new URL(url):new URL(url,staticVideoUrl);return completeUrl.href;}function getVideoQualityBySize(sources,_ref){let{width,height}=_ref;const targetQuality=sources.find(value=>value.width*value.height>width*height);return targetQuality||sources[sources.length-1];}function getScaleFactor(containerWidth,containerHeight,videoWidth,videoHeight){return{wScale:containerWidth/videoWidth,hScale:containerHeight/videoHeight};}function getVideoDimension(videoScale,videoWidth,videoHeight){const scale=Math.min(videoScale.wScale,videoScale.hScale);return{width:Math.round(videoWidth*scale),height:Math.round(videoHeight*scale)};}function setVideoFocalPoint(videoNode,focalPoint){const focalX=(focalPoint==null?void 0:focalPoint.x)??50;const focalY=(focalPoint==null?void 0:focalPoint.y)??50;videoNode.style.setProperty('--focal-x',focalX.toString());videoNode.style.setProperty('--focal-y',focalY.toString());}async function getVideoSource(width,height,uri,qualityPolicy,sources,adaptiveSources,duration,onError){const hasProgressiveSources=sources&&sources.length>0;const hasAbsoluteUri=uri&&isAbsoluteUrl(uri);const shouldSkipAdaptiveShortVideo=duration&&duration<40;if(qualityPolicy==='adaptive'&&adaptiveSources&&adaptiveSources.length>0&&!shouldSkipAdaptiveShortVideo){const hlsSource=adaptiveSources.find(s=>s.format==='hls');const Hls=await __webpack_require__.e(/* import() */ 470).then(__webpack_require__.bind(__webpack_require__, 46089));if(hlsSource&&Hls&&Hls.default.isSupported()){const videoSourceUrl=getCompleteUrl(hlsSource.uri,STATIC_ADAPTIVE_VIDEO_URL);const patchVideoSource=videoNode=>{const hls=new Hls.default();hls.loadSource(videoSourceUrl);hls.attachMedia(videoNode);hls.on(Hls.default.Events.ERROR,(_,data)=>{if(data.fatal){switch(data.type){case Hls.default.ErrorTypes.NETWORK_ERROR:hls.startLoad();if(onError){onError(new Error(`HLS Network Error: ${data.details}.\nAttempting to reconnect...`));}break;case Hls.default.ErrorTypes.MEDIA_ERROR:hls.recoverMediaError();if(onError){onError(new Error(`HLS Media Error: ${data.details}.\nAttempting to recover...`));}break;default:hls.destroy();if(onError){onError(new Error(`HLS Unknown Error: ${data.details}.\nUnrecoverable playback error`));}break;}}});};return{videoSourceUrl,patchVideoSource};}}if(hasProgressiveSources){const highestQuality=sources[sources.length-1];if(qualityPolicy==='highest'){var _highestQuality$types;const url=(_highestQuality$types=highestQuality.types.find(type=>type.format==='mp4'))==null?void 0:_highestQuality$types.uri;if(url){const videoSourceUrl=getCompleteUrl(url,STATIC_VIDEO_URL);return{videoSourceUrl,patchVideoSource:videoNode=>{videoNode.src=videoSourceUrl;videoNode.load();}};}}else{var _targetQuality$types$;const videoWidth=parseInt(highestQuality.width.toString(),10);const videoHeight=parseInt(highestQuality.height.toString(),10);const scaleFactor=getScaleFactor(width,height,videoWidth,videoHeight);const videoScaledDimensions=getVideoDimension(scaleFactor,videoWidth,videoHeight);const targetQuality=getVideoQualityBySize(sources,videoScaledDimensions);const url=(_targetQuality$types$=targetQuality.types.find(type=>type.format==='mp4'))==null?void 0:_targetQuality$types$.uri;if(url){const videoSourceUrl=getCompleteUrl(url,STATIC_VIDEO_URL);return{videoSourceUrl,patchVideoSource:videoNode=>{videoNode.src=videoSourceUrl;videoNode.load();}};}}}if(hasAbsoluteUri){return{videoSourceUrl:uri,patchVideoSource:videoNode=>{videoNode.src=uri;videoNode.load();}};}return{videoSourceUrl:'',patchVideoSource:()=>{}};}
15701
+ const STATIC_VIDEO_URL='https://video.wixstatic.com/';const STATIC_ADAPTIVE_VIDEO_URL='https://files.wix.com/';const isAbsoluteUrl=url=>url.startsWith('http://')||url.startsWith('https://');function sortQualities(sources){return sources.sort((a,b)=>a.width*a.height-b.width*b.height);}function getCompleteUrl(url,staticVideoUrl){const completeUrl=isAbsoluteUrl(url)?new URL(url):new URL(url,staticVideoUrl);return completeUrl.href;}function getVideoQualityBySize(sources,_ref){let{width,height}=_ref;const targetQuality=sources.find(value=>value.width*value.height>width*height);return targetQuality||sources[sources.length-1];}function getScaleFactor(containerWidth,containerHeight,videoWidth,videoHeight){return{wScale:containerWidth/videoWidth,hScale:containerHeight/videoHeight};}function getVideoDimension(videoScale,videoWidth,videoHeight){const scale=Math.min(videoScale.wScale,videoScale.hScale);return{width:Math.round(videoWidth*scale),height:Math.round(videoHeight*scale)};}function setVideoFocalPoint(videoNode,focalPoint){const computedStyle=getComputedStyle(videoNode);const videoFit=computedStyle.getPropertyValue('--video-fit');if(videoFit==='contain'){videoNode.style.setProperty('object-position','center');return;}videoNode.style.removeProperty('object-position');const focalX=(focalPoint==null?void 0:focalPoint.x)??50;const focalY=(focalPoint==null?void 0:focalPoint.y)??50;videoNode.style.setProperty('--focal-x',focalX.toString());videoNode.style.setProperty('--focal-y',focalY.toString());}async function getVideoSource(width,height,uri,qualityPolicy,sources,adaptiveSources,duration,onError){const hasProgressiveSources=sources&&sources.length>0;const hasAbsoluteUri=uri&&isAbsoluteUrl(uri);const shouldSkipAdaptiveShortVideo=duration&&duration<40;if(qualityPolicy==='adaptive'&&adaptiveSources&&adaptiveSources.length>0&&!shouldSkipAdaptiveShortVideo){const hlsSource=adaptiveSources.find(s=>s.format==='hls');const Hls=await __webpack_require__.e(/* import() */ 470).then(__webpack_require__.bind(__webpack_require__, 46089));if(hlsSource&&Hls&&Hls.default.isSupported()){const videoSourceUrl=getCompleteUrl(hlsSource.uri,STATIC_ADAPTIVE_VIDEO_URL);const patchVideoSource=videoNode=>{const hls=new Hls.default();hls.loadSource(videoSourceUrl);hls.attachMedia(videoNode);hls.on(Hls.default.Events.ERROR,(_,data)=>{if(data.fatal){switch(data.type){case Hls.default.ErrorTypes.NETWORK_ERROR:hls.startLoad();if(onError){onError(new Error(`HLS Network Error: ${data.details}.\nAttempting to reconnect...`));}break;case Hls.default.ErrorTypes.MEDIA_ERROR:hls.recoverMediaError();if(onError){onError(new Error(`HLS Media Error: ${data.details}.\nAttempting to recover...`));}break;default:hls.destroy();if(onError){onError(new Error(`HLS Unknown Error: ${data.details}.\nUnrecoverable playback error`));}break;}}});};return{videoSourceUrl,patchVideoSource};}}if(hasProgressiveSources){const highestQuality=sources[sources.length-1];if(qualityPolicy==='highest'){var _highestQuality$types;const url=(_highestQuality$types=highestQuality.types.find(type=>type.format==='mp4'))==null?void 0:_highestQuality$types.uri;if(url){const videoSourceUrl=getCompleteUrl(url,STATIC_VIDEO_URL);return{videoSourceUrl,patchVideoSource:videoNode=>{videoNode.src=videoSourceUrl;videoNode.load();}};}}else{var _targetQuality$types$;const videoWidth=parseInt(highestQuality.width.toString(),10);const videoHeight=parseInt(highestQuality.height.toString(),10);const scaleFactor=getScaleFactor(width,height,videoWidth,videoHeight);const videoScaledDimensions=getVideoDimension(scaleFactor,videoWidth,videoHeight);const targetQuality=getVideoQualityBySize(sources,videoScaledDimensions);const url=(_targetQuality$types$=targetQuality.types.find(type=>type.format==='mp4'))==null?void 0:_targetQuality$types$.uri;if(url){const videoSourceUrl=getCompleteUrl(url,STATIC_VIDEO_URL);return{videoSourceUrl,patchVideoSource:videoNode=>{videoNode.src=videoSourceUrl;videoNode.load();}};}}}if(hasAbsoluteUri){return{videoSourceUrl:uri,patchVideoSource:videoNode=>{videoNode.src=uri;videoNode.load();}};}return{videoSourceUrl:'',patchVideoSource:()=>{}};}
15702
15702
  // EXTERNAL MODULE: ../../node_modules/@babel/runtime/helpers/defineProperty.js
15703
15703
  var defineProperty = __webpack_require__(58212);
15704
15704
  var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
@@ -19089,11 +19089,12 @@ const Image = (props) => {
19089
19089
  ;// ./src/Video.tsx
19090
19090
  if(typeof window!=='undefined'){if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',()=>{initCustomElement();customElementInit_initCustomElement();},{once:true});}else{initCustomElement();customElementInit_initCustomElement();}}const Video=props=>{const{motionPart,videoRef,videoMedia,muted,loop,autoplay,playbackRate=1,posterEffect,id,qualityPolicy='proportional',focalPoint={x:50,y:50},onError}=props;const wowVideoRef=react.useRef(null);const videoInfoString=react.useMemo(()=>{const sortedQualities=sortQualities(videoMedia.sources||[]);return JSON.stringify({...videoMedia,playbackRate,posterEffect,sources:sortedQualities,autoplay,qualityPolicy,focalPoint});},[videoMedia,playbackRate,posterEffect,autoplay,qualityPolicy,focalPoint]);const VideoPosterImage=videoMedia.poster&&/*#__PURE__*/react.createElement(Image,extends_default()({},videoMedia.poster,{focalPoint:focalPoint,id:`videoPoster_${id}`,displayMode:"fill",alt:videoMedia.name||videoMedia.poster.alt||"",quality:videoMedia.poster.quality?{quality:videoMedia.poster.quality}:undefined}));const handleVideoElementError=react.useCallback(event=>{if(onError){var _videoElement$error;const videoElement=event.currentTarget;const error=new Error(`Video playback error: ${((_videoElement$error=videoElement.error)==null?void 0:_videoElement$error.message)||"Unknown error"}`);onError(error);}},[onError]);const handleAdaptiveVideoError=react.useCallback(event=>{var _event$detail;if(onError&&(_event$detail=event.detail)!=null&&_event$detail.error){onError(event.detail.error);}},[onError]);react.useEffect(()=>{const element=wowVideoRef.current;element==null||element.addEventListener("videoerror",handleAdaptiveVideoError);return()=>{element==null||element.removeEventListener("videoerror",handleAdaptiveVideoError);};},[onError,handleAdaptiveVideoError]);return/*#__PURE__*/react.createElement("wow-video",{ref:wowVideoRef,"data-video-info":videoInfoString,"data-motion-part":motionPart||'',class:src_Video_module.videoContainer},/*#__PURE__*/react.createElement("video",{ref:videoRef,className:src_Video_module.video,crossOrigin:"anonymous",playsInline:true,muted:muted,loop:loop,preload:"none",onError:handleVideoElementError}),VideoPosterImage);};/* harmony default export */ const src_Video = (Video);
19091
19091
  ;// ./src/storybook/Container.tsx
19092
- const Container=_ref=>{let{id,width,height,children}=_ref;return/*#__PURE__*/react.createElement("div",{id:id,style:{width,height,border:'1px solid red'}},/*#__PURE__*/react.cloneElement(children,{containerWidth:width,containerHeight:height}));};
19092
+ const Container=_ref=>{let{id,width,height,fullscreen,children}=_ref;const containerStyle=fullscreen?{position:'fixed',inset:0,backgroundColor:'#000'}:{width,height,border:'1px solid red'};const videoContainerStyle=fullscreen?{width:'100%',height:'100%',// @ts-expect-error CSS variable
19093
+ '--video-fit':'contain','--video-position':'center'}:{width:'100%',height:'100%'};return/*#__PURE__*/react.createElement("div",{id:id,style:containerStyle},/*#__PURE__*/react.createElement("div",{style:videoContainerStyle},/*#__PURE__*/react.cloneElement(children,{containerWidth:fullscreen?window.innerWidth:width,containerHeight:fullscreen?window.innerHeight:height})));};
19093
19094
  ;// ./src/storybook/args.ts
19094
- const sampleVideo={videoMedia:{sources:[{quality:'1080p',width:1920,height:1080,types:[{format:'mp4',uri:'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4'}]},{quality:'720p',width:1280,height:720,types:[{format:'mp4',uri:'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4'}]},{quality:'480p',width:854,height:480,types:[{format:'mp4',uri:'video/11062b_c1797898279949878ff9bc792dc4a79c/480p/mp4/file.mp4'}]},{quality:'360p',width:640,height:360,types:[{format:'mp4',uri:'video/11062b_c1797898279949878ff9bc792dc4a79c/360p/mp4/file.mp4'}]}],adaptiveSources:[{format:'hls',uri:'site/media/video/11062b_c1797898279949878ff9bc792dc4a79c/da01a1fc-ad34-44bc-90e8-cc9413c466e6/repackage/hls'}],uri:'test-meta-id',hasAudio:true,fps:30,duration:40,poster:{id:'video-poster',uri:'11062b_c1797898279949878ff9bc792dc4a79cf000.jpg',width:1440,height:2560,name:'video-poster.jpg',alt:'alt text'}},loop:true,muted:true,autoplay:true,posterEffect:'none',playbackRate:1,qualityPolicy:'proportional'};const argTypes={qualityPolicy:{control:'select',options:['proportional','adaptive','highest','none'],defaultValue:'proportional',description:'Quality policy for the video',table:{type:{summary:'enum'}}},containerWidth:{control:'number',defaultValue:500,description:'Width in pixels of the container element',table:{type:{summary:'number'}}},containerHeight:{control:'number',defaultValue:275,description:'Height in pixels of the container element',table:{type:{summary:'number'}}},muted:{control:'boolean',defaultValue:true,description:'Whether the video should be muted',table:{type:{summary:'boolean'}}},loop:{control:'boolean',defaultValue:true,description:'Whether the video should loop continuously',table:{type:{summary:'boolean'}}},posterEffect:{control:'select',options:[undefined,'fade'],defaultValue:undefined,description:'Effect to apply when transitioning from poster to video',table:{type:{summary:'string'}}},playbackRate:{control:'number',defaultValue:1,description:'The playback rate of the video',table:{type:{summary:'number'}}},autoplay:{control:'boolean',defaultValue:true,description:'Whether the video should autoplay',table:{type:{summary:'boolean'}}},focalPointX:{control:{type:'range',min:0,max:100,step:5},defaultValue:50,description:'Horizontal focal point for video positioning (0 = left, 100 = right)',table:{type:{summary:'number'}}},focalPointY:{control:{type:'range',min:0,max:100,step:5},defaultValue:50,description:'Vertical focal point for video positioning (0 = top, 100 = bottom)',table:{type:{summary:'number'}}}};
19095
+ const sampleVideo={videoMedia:{sources:[{quality:'1080p',width:1920,height:1080,types:[{format:'mp4',uri:'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4'}]},{quality:'720p',width:1280,height:720,types:[{format:'mp4',uri:'video/11062b_c1797898279949878ff9bc792dc4a79c/1080p/mp4/file.mp4'}]},{quality:'480p',width:854,height:480,types:[{format:'mp4',uri:'video/11062b_c1797898279949878ff9bc792dc4a79c/480p/mp4/file.mp4'}]},{quality:'360p',width:640,height:360,types:[{format:'mp4',uri:'video/11062b_c1797898279949878ff9bc792dc4a79c/360p/mp4/file.mp4'}]}],adaptiveSources:[{format:'hls',uri:'site/media/video/11062b_c1797898279949878ff9bc792dc4a79c/da01a1fc-ad34-44bc-90e8-cc9413c466e6/repackage/hls'}],uri:'test-meta-id',hasAudio:true,fps:30,duration:40,poster:{id:'video-poster',uri:'11062b_c1797898279949878ff9bc792dc4a79cf000.jpg',width:1440,height:2560,name:'video-poster.jpg',alt:'alt text'}},loop:true,muted:true,autoplay:true,posterEffect:'none',playbackRate:1,qualityPolicy:'proportional'};const argTypes={fullscreen:{control:'boolean',defaultValue:false,description:'Toggle fullscreen mode. In fullscreen, the video is centered and contained.',table:{type:{summary:'boolean'}}},qualityPolicy:{control:'select',options:['proportional','adaptive','highest','none'],defaultValue:'proportional',description:'Quality policy for the video',table:{type:{summary:'enum'}}},containerWidth:{control:'number',defaultValue:500,description:'Width in pixels of the container element',table:{type:{summary:'number'}}},containerHeight:{control:'number',defaultValue:275,description:'Height in pixels of the container element',table:{type:{summary:'number'}}},muted:{control:'boolean',defaultValue:true,description:'Whether the video should be muted',table:{type:{summary:'boolean'}}},loop:{control:'boolean',defaultValue:true,description:'Whether the video should loop continuously',table:{type:{summary:'boolean'}}},posterEffect:{control:'select',options:[undefined,'fade'],defaultValue:undefined,description:'Effect to apply when transitioning from poster to video',table:{type:{summary:'string'}}},playbackRate:{control:'number',defaultValue:1,description:'The playback rate of the video',table:{type:{summary:'number'}}},autoplay:{control:'boolean',defaultValue:true,description:'Whether the video should autoplay',table:{type:{summary:'boolean'}}},focalPointX:{control:{type:'range',min:0,max:100,step:5},defaultValue:50,description:'Horizontal focal point for video positioning (0 = left, 100 = right)',table:{type:{summary:'number'}}},focalPointY:{control:{type:'range',min:0,max:100,step:5},defaultValue:50,description:'Vertical focal point for video positioning (0 = top, 100 = bottom)',table:{type:{summary:'number'}}}};
19095
19096
  ;// ./src/Video.stories.tsx
19096
- const openExperiments=[];const urlParams=new URLSearchParams(window.location.search);const experimentsParam=urlParams.get('experiments');((experimentsParam==null?void 0:experimentsParam.split(','))||[]).forEach(experiment=>{openExperiments.push(experiment);});/* harmony default export */ const Video_stories = ({title:'Video',component:src_Video,argTypes: argTypes});const Default=args=>{const id='comp_12345';const videoRef=react.useRef(null);react.useEffect(()=>{if(videoRef.current){videoRef.current.load();}},[args.autoplay,args.qualityPolicy]);const videoProps={loop:Boolean(args.loop),muted:Boolean(args.muted),playbackRate:args.playbackRate,posterEffect:args.posterEffect,autoplay:Boolean(args.autoplay),videoMedia:sampleVideo.videoMedia,id,videoRef,qualityPolicy:args.qualityPolicy,focalPoint:{x:args.focalPointX,y:args.focalPointY},onError:error=>{console.log('Video error:',error);}};return/*#__PURE__*/react.createElement(Container,{width:args.containerWidth,height:args.containerHeight},/*#__PURE__*/react.createElement(src_Video,videoProps));};
19097
+ const openExperiments=[];const urlParams=new URLSearchParams(window.location.search);const experimentsParam=urlParams.get('experiments');((experimentsParam==null?void 0:experimentsParam.split(','))||[]).forEach(experiment=>{openExperiments.push(experiment);});/* harmony default export */ const Video_stories = ({title:'Video',component:src_Video,argTypes: argTypes});const Default=args=>{const id='comp_12345';const videoRef=react.useRef(null);react.useEffect(()=>{if(videoRef.current){videoRef.current.load();}},[args.autoplay,args.qualityPolicy]);const videoProps={loop:Boolean(args.loop),muted:Boolean(args.muted),playbackRate:args.playbackRate,posterEffect:args.posterEffect,autoplay:Boolean(args.autoplay),videoMedia:sampleVideo.videoMedia,id,videoRef,qualityPolicy:args.qualityPolicy,focalPoint:{x:args.focalPointX,y:args.focalPointY},onError:error=>{console.log('Video error:',error);}};return/*#__PURE__*/react.createElement(Container,{width:args.containerWidth,height:args.containerHeight,fullscreen:args.fullscreen},/*#__PURE__*/react.createElement(src_Video,videoProps));};
19097
19098
 
19098
19099
  /***/ }),
19099
19100
 
@@ -73257,4 +73258,4 @@ module.exports = /*#__PURE__*/JSON.parse('["a","abbr","address","area","article"
73257
73258
  /******/
73258
73259
  /******/ })()
73259
73260
  ;
73260
- //# sourceMappingURL=main.f45a6aa8.iframe.bundle.js.map
73261
+ //# sourceMappingURL=main.4e295f79.iframe.bundle.js.map