Skip to content

Commit a5ad45f

Browse files
committed
feat(player): enhance device shell rendering and improve progress calculation
1 parent f1d8200 commit a5ad45f

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

packages/visualizer/src/component/player/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,22 @@ export function Player(props?: {
8181
}, [props?.autoZoom, setAutoZoom]);
8282

8383
const scripts = props?.replayScripts;
84-
const imageWidth = props?.imageWidth || 1920;
85-
const imageHeight = props?.imageHeight || 1080;
86-
8784
const deviceType = props?.deviceType;
8885
const frameMap = useMemo<FrameMap | null>(() => {
8986
if (!scripts || scripts.length === 0) return null;
9087
return calculateFrameMap(scripts, {
9188
effects: effectsEnabled,
92-
playbackSpeed: 1, // Speed handled by Remotion's playbackRate
9389
deviceType,
9490
});
9591
}, [scripts, effectsEnabled, deviceType]);
9692

9793
const playerRef = useRef<PlayerRef>(null);
94+
const lastTaskIdRef = useRef<string | null>(null);
9895

9996
// Track frame for taskId callback
10097
useEffect(() => {
10198
if (!frameMap || !props?.onTaskChange) return;
99+
lastTaskIdRef.current = null;
102100
const interval = setInterval(() => {
103101
const player = playerRef.current;
104102
if (!player) return;
@@ -108,7 +106,10 @@ export function Player(props?: {
108106
stepsFrame >= 0
109107
? deriveTaskId(frameMap.scriptFrames, stepsFrame)
110108
: null;
111-
props.onTaskChange!(taskId);
109+
if (taskId !== lastTaskIdRef.current) {
110+
lastTaskIdRef.current = taskId;
111+
props.onTaskChange!(taskId);
112+
}
112113
}, 200);
113114
return () => clearInterval(interval);
114115
}, [frameMap, props?.onTaskChange]);
@@ -327,7 +328,7 @@ export function Player(props?: {
327328
const compositionHeight = frameMap.imageHeight;
328329

329330
return (
330-
<div className="player-container">
331+
<div className="player-container" data-fit-mode={props?.fitMode}>
331332
<div className="canvas-container">
332333
<RemotionPlayer
333334
ref={playerRef}

packages/visualizer/src/component/player/remotion/ProgressBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const ProgressBar: React.FC = () => {
99
const frame = useCurrentFrame();
1010
const { durationInFrames } = useVideoConfig();
1111

12-
const progress = interpolate(frame, [0, durationInFrames], [0, 100], {
12+
const progress = interpolate(frame, [0, durationInFrames - 1], [0, 100], {
1313
extrapolateRight: 'clamp',
1414
});
1515

packages/visualizer/src/component/player/remotion/export-branded-video.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ export async function exportBrandedVideo(
10971097
}
10981098

10991099
if (effects) drawProgressBar(ctx, f, total);
1100-
onProgress?.(f / total);
1100+
onProgress?.((f + 1) / total);
11011101
}
11021102

11031103
if (targetFrame < total - 1) {

packages/visualizer/src/component/player/remotion/frame-calculator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export interface ScriptFrame {
5151

5252
export interface FrameMapOptions {
5353
effects: boolean; // include opening/ending
54-
playbackSpeed: number; // affects duration-to-frames conversion
5554
}
5655

5756
export interface FrameMap {

packages/visualizer/src/component/player/remotion/visual-effects.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,13 @@ export function resolveShellType(deviceType?: string): DeviceShellType {
390390
case 'android':
391391
return 'android';
392392
case 'ios':
393+
case 'iphone':
393394
return 'iphone';
394395
case 'computer':
396+
case 'desktop-app':
395397
return 'desktop-app';
398+
case 'desktop-browser':
399+
return 'desktop-browser';
396400
default:
397401
return 'desktop-browser';
398402
}

0 commit comments

Comments
 (0)