@zync/zync-screnplay-player 0.1.238 → 0.1.239

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.
@@ -16,8 +16,9 @@ var TEXT_COLOR = "#0a3567";
16
16
  var BACKGROUND_COLORS = ["#fff200", "#22f3d0", "#ff8a00", "#ff78a8", "#b9ff4a", "#f7f7f2"];
17
17
  var HORIZONTAL_SAFE_AREA = 0.86;
18
18
  var VERTICAL_SAFE_AREA = 0.5;
19
- var BACKGROUND_WIPE_FRAMES = 7;
20
- var WORD_STEP_FRAMES = 18;
19
+ var MAX_BACKGROUND_WIPE_FRAMES = 7;
20
+ var MAX_WORD_STEP_FRAMES = 18;
21
+ var WORD_REVEAL_SECONDS = 3;
21
22
  var splitWords = function splitWords() {
22
23
  var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
23
24
  return String(text).trim().split(/\s+/).filter(Boolean);
@@ -83,13 +84,25 @@ var getFontSizeForFullText = function getFontSizeForFullText(_ref2) {
83
84
  var getBackgroundColor = function getBackgroundColor(index) {
84
85
  return BACKGROUND_COLORS[index % BACKGROUND_COLORS.length];
85
86
  };
86
- var PositionedWords = function PositionedWords(_ref3) {
87
- var fontSize = _ref3.fontSize,
88
- frame = _ref3.frame,
89
- staticUntilIndex = _ref3.staticUntilIndex,
90
- visibleUntilIndex = _ref3.visibleUntilIndex,
91
- width = _ref3.width,
92
- words = _ref3.words;
87
+ var getWordStepFrames = function getWordStepFrames(_ref3) {
88
+ var fps = _ref3.fps,
89
+ wordCount = _ref3.wordCount;
90
+ if (wordCount <= 1) {
91
+ return MAX_WORD_STEP_FRAMES;
92
+ }
93
+ var revealFrames = fps * WORD_REVEAL_SECONDS;
94
+ var maxStepFrames = Math.floor(revealFrames / (wordCount - 1));
95
+ return Math.max(1, Math.min(MAX_WORD_STEP_FRAMES, maxStepFrames));
96
+ };
97
+ var PositionedWords = function PositionedWords(_ref4) {
98
+ var backgroundWipeFrames = _ref4.backgroundWipeFrames,
99
+ fontSize = _ref4.fontSize,
100
+ frame = _ref4.frame,
101
+ staticUntilIndex = _ref4.staticUntilIndex,
102
+ visibleUntilIndex = _ref4.visibleUntilIndex,
103
+ width = _ref4.width,
104
+ wordStepFrames = _ref4.wordStepFrames,
105
+ words = _ref4.words;
93
106
  return /*#__PURE__*/React.createElement(AbsoluteFill, {
94
107
  style: {
95
108
  alignItems: "center",
@@ -120,8 +133,8 @@ var PositionedWords = function PositionedWords(_ref3) {
120
133
  }, word);
121
134
  }
122
135
  var shouldAnimate = index > staticUntilIndex;
123
- var wordFrame = frame - index * WORD_STEP_FRAMES;
124
- var progress = shouldAnimate ? interpolate(wordFrame, [0, BACKGROUND_WIPE_FRAMES + 5], [0, 1], {
136
+ var wordFrame = frame - index * wordStepFrames;
137
+ var progress = shouldAnimate ? interpolate(wordFrame, [0, backgroundWipeFrames + 5], [0, 1], {
125
138
  easing: Easing.out(Easing.cubic),
126
139
  extrapolateLeft: "clamp",
127
140
  extrapolateRight: "clamp"
@@ -151,19 +164,20 @@ var PositionedWords = function PositionedWords(_ref3) {
151
164
  }, word);
152
165
  })));
153
166
  };
154
- export var TextFullCover = function TextFullCover(_ref4) {
155
- var text = _ref4.text,
156
- children = _ref4.children,
157
- muted = _ref4.muted,
158
- _ref4$startVideoFrom = _ref4.startVideoFrom,
159
- startVideoFrom = _ref4$startVideoFrom === void 0 ? 0 : _ref4$startVideoFrom,
160
- videoUrl = _ref4.videoUrl,
161
- _ref4$videoZoom = _ref4.videoZoom,
162
- videoZoom = _ref4$videoZoom === void 0 ? 1 : _ref4$videoZoom,
163
- _ref4$disableTransiti = _ref4.disableTransitionSounds,
164
- disableTransitionSounds = _ref4$disableTransiti === void 0 ? false : _ref4$disableTransiti;
167
+ export var TextFullCover = function TextFullCover(_ref5) {
168
+ var text = _ref5.text,
169
+ children = _ref5.children,
170
+ muted = _ref5.muted,
171
+ _ref5$startVideoFrom = _ref5.startVideoFrom,
172
+ startVideoFrom = _ref5$startVideoFrom === void 0 ? 0 : _ref5$startVideoFrom,
173
+ videoUrl = _ref5.videoUrl,
174
+ _ref5$videoZoom = _ref5.videoZoom,
175
+ videoZoom = _ref5$videoZoom === void 0 ? 1 : _ref5$videoZoom,
176
+ _ref5$disableTransiti = _ref5.disableTransitionSounds,
177
+ disableTransitionSounds = _ref5$disableTransiti === void 0 ? false : _ref5$disableTransiti;
165
178
  var frame = useCurrentFrame();
166
179
  var _useVideoConfig = useVideoConfig(),
180
+ fps = _useVideoConfig.fps,
167
181
  width = _useVideoConfig.width,
168
182
  height = _useVideoConfig.height;
169
183
  var words = splitWords(text);
@@ -171,14 +185,19 @@ export var TextFullCover = function TextFullCover(_ref4) {
171
185
  var uppercaseWords = fallbackWords.map(function (word) {
172
186
  return word.toLocaleUpperCase();
173
187
  });
188
+ var wordStepFrames = getWordStepFrames({
189
+ fps: fps,
190
+ wordCount: fallbackWords.length
191
+ });
192
+ var backgroundWipeFrames = Math.min(MAX_BACKGROUND_WIPE_FRAMES, Math.max(1, wordStepFrames - 1));
174
193
  var lastStepIndex = fallbackWords.length - 1;
175
- var stepIndex = Math.min(lastStepIndex, Math.floor(frame / WORD_STEP_FRAMES));
194
+ var stepIndex = Math.min(lastStepIndex, Math.floor(frame / wordStepFrames));
176
195
  var previousStepIndex = Math.max(0, stepIndex - 1);
177
- var frameInWord = frame - stepIndex * WORD_STEP_FRAMES;
196
+ var frameInWord = frame - stepIndex * wordStepFrames;
178
197
  var currentBackgroundColor = getBackgroundColor(stepIndex);
179
198
  var previousBackgroundColor = getBackgroundColor(Math.max(0, stepIndex - 1));
180
- var shouldWipe = stepIndex > 0 && frameInWord < BACKGROUND_WIPE_FRAMES;
181
- var wipeProgress = shouldWipe ? interpolate(frameInWord, [0, BACKGROUND_WIPE_FRAMES], [0, 1], {
199
+ var shouldWipe = stepIndex > 0 && frameInWord < backgroundWipeFrames;
200
+ var wipeProgress = shouldWipe ? interpolate(frameInWord, [0, backgroundWipeFrames], [0, 1], {
182
201
  easing: Easing.out(Easing.cubic),
183
202
  extrapolateLeft: "clamp",
184
203
  extrapolateRight: "clamp"
@@ -215,11 +234,13 @@ export var TextFullCover = function TextFullCover(_ref4) {
215
234
  width: "100%"
216
235
  }
217
236
  })) : null, shouldWipe ? /*#__PURE__*/React.createElement(PositionedWords, {
237
+ backgroundWipeFrames: backgroundWipeFrames,
218
238
  fontSize: fontSize,
219
239
  frame: frame,
220
240
  staticUntilIndex: previousStepIndex,
221
241
  visibleUntilIndex: previousStepIndex,
222
242
  width: width,
243
+ wordStepFrames: wordStepFrames,
223
244
  words: uppercaseWords
224
245
  }) : null, /*#__PURE__*/React.createElement(AbsoluteFill, {
225
246
  style: {
@@ -232,11 +253,13 @@ export var TextFullCover = function TextFullCover(_ref4) {
232
253
  zIndex: 1
233
254
  }
234
255
  }, /*#__PURE__*/React.createElement(PositionedWords, {
256
+ backgroundWipeFrames: backgroundWipeFrames,
235
257
  fontSize: fontSize,
236
258
  frame: frame,
237
259
  staticUntilIndex: previousStepIndex,
238
260
  visibleUntilIndex: stepIndex,
239
261
  width: width,
262
+ wordStepFrames: wordStepFrames,
240
263
  words: uppercaseWords
241
264
  })), !disableTransitionSounds && /*#__PURE__*/React.createElement(Audio, {
242
265
  src: "https://cdn.zync.ai/assets/static/swoosh.mp3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zync/zync-screnplay-player",
3
- "version": "0.1.238",
3
+ "version": "0.1.239",
4
4
  "files": [
5
5
  "dist"
6
6
  ],