@app-studio/web 0.8.61 → 0.8.63

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.
@@ -6949,6 +6949,26 @@
6949
6949
  return visible ? MessageContainer : null;
6950
6950
  };
6951
6951
 
6952
+ var generateThumbnail = (videoFile, setThumbnailUrl) => {
6953
+ var video = document.createElement('video');
6954
+ video.preload = 'metadata';
6955
+ video.onloadedmetadata = () => {
6956
+ video.currentTime = 1;
6957
+ };
6958
+ video.oncanplay = () => {
6959
+ var canvas = document.createElement('canvas');
6960
+ canvas.width = video.videoWidth;
6961
+ canvas.height = video.videoHeight;
6962
+ var ctx = canvas.getContext('2d');
6963
+ if (ctx) {
6964
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
6965
+ var thumbnailDataUrl = canvas.toDataURL('image/jpeg');
6966
+ setThumbnailUrl(thumbnailDataUrl);
6967
+ }
6968
+ URL.revokeObjectURL(video.src);
6969
+ };
6970
+ video.src = URL.createObjectURL(videoFile);
6971
+ };
6952
6972
  var useUpload = _ref => {
6953
6973
  var {
6954
6974
  maxSize = 100 * 1024 * 1024,
@@ -6966,26 +6986,6 @@
6966
6986
  var [errorMessage, setErrorMessage] = React.useState(null);
6967
6987
  var [previewUrl, setPreviewUrl] = React.useState(null);
6968
6988
  var [thumbnailUrl, setThumbnailUrl] = React.useState(thumbnail || null);
6969
- var generateThumbnail = videoFile => {
6970
- var video = document.createElement('video');
6971
- video.preload = 'metadata';
6972
- video.onloadedmetadata = () => {
6973
- video.currentTime = 1;
6974
- };
6975
- video.oncanplay = () => {
6976
- var canvas = document.createElement('canvas');
6977
- canvas.width = video.videoWidth;
6978
- canvas.height = video.videoHeight;
6979
- var ctx = canvas.getContext('2d');
6980
- if (ctx) {
6981
- ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
6982
- var thumbnailDataUrl = canvas.toDataURL('image/jpeg');
6983
- setThumbnailUrl(thumbnailDataUrl);
6984
- }
6985
- URL.revokeObjectURL(video.src);
6986
- };
6987
- video.src = URL.createObjectURL(videoFile);
6988
- };
6989
6989
  var handleFileChange = React.useCallback(event => {
6990
6990
  var _event$target$files;
6991
6991
  var file = (_event$target$files = event.target.files) == null ? void 0 : _event$target$files[0];
@@ -7010,7 +7010,7 @@
7010
7010
  }
7011
7011
  setPreviewUrl(URL.createObjectURL(file));
7012
7012
  if (file.type.startsWith('video/')) {
7013
- generateThumbnail(file);
7013
+ generateThumbnail(file, setThumbnailUrl);
7014
7014
  }
7015
7015
  if (onFileSelect) {
7016
7016
  setSelectedFile(file);
@@ -7094,8 +7094,7 @@
7094
7094
  thumbnailUrl,
7095
7095
  videoRef,
7096
7096
  videoProps,
7097
- imageProps,
7098
- iconProps
7097
+ imageProps
7099
7098
  } = _ref6;
7100
7099
  console.log('thumbnailUrl', thumbnailUrl);
7101
7100
  return /*#__PURE__*/React__default.createElement(appStudio.View, {
@@ -7117,14 +7116,7 @@
7117
7116
  width: "100%",
7118
7117
  height: "100%",
7119
7118
  objectFit: "cover"
7120
- }, imageProps)), /*#__PURE__*/React__default.createElement(PlayIcon, Object.assign({
7121
- position: "absolute",
7122
- top: "50%",
7123
- left: "50%",
7124
- color: "white",
7125
- size: '20%',
7126
- transform: "translate(-50%, -50%)"
7127
- }, iconProps)));
7119
+ }, imageProps)));
7128
7120
  },
7129
7121
  renderImage = _ref7 => {
7130
7122
  var {
@@ -8183,6 +8175,7 @@
8183
8175
  exports.WifiIcon = WifiIcon;
8184
8176
  exports.XIcon = XIcon;
8185
8177
  exports.YoutubeIcon = YoutubeIcon;
8178
+ exports.generateThumbnail = generateThumbnail;
8186
8179
  exports.hideMessage = hideMessage;
8187
8180
  exports.hideModal = hideModal;
8188
8181
  exports.showMessage = showMessage;