Skip to content

Commit f314292

Browse files
committed
feat(player): update custom controls with play/pause button and improve button styles
1 parent a5ad45f commit f314292

File tree

2 files changed

+82
-45
lines changed

2 files changed

+82
-45
lines changed

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

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,11 @@
5656
max-height: 100%;
5757
border: none;
5858
}
59-
}
60-
61-
// Shared icon style for custom controls & fullscreen button in Remotion control bar
62-
.status-icon {
63-
transition: 0.2s;
64-
width: 24px;
65-
height: 24px;
66-
border-radius: 4px;
67-
display: flex;
68-
align-items: center;
69-
justify-content: center;
70-
flex-shrink: 0;
71-
color: #fff;
72-
cursor: pointer;
73-
74-
svg {
75-
color: #fff;
76-
font-size: 14px;
77-
}
7859

79-
&:hover {
80-
background: rgba(255, 255, 255, 0.15);
60+
// Remove border/outline from Remotion control bar buttons
61+
button {
62+
border: none;
63+
outline: none;
8164
}
8265
}
8366

@@ -86,11 +69,34 @@
8669
display: flex;
8770
flex-direction: row;
8871
align-items: center;
89-
gap: 2px;
72+
gap: 8px;
73+
margin-right: 8px;
9074

9175
.ant-spin {
9276
color: #fff;
9377
}
78+
79+
.status-icon {
80+
transition: 0.2s;
81+
width: 24px;
82+
height: 24px;
83+
border-radius: 4px;
84+
display: flex;
85+
align-items: center;
86+
justify-content: center;
87+
flex-shrink: 0;
88+
color: #fff;
89+
cursor: pointer;
90+
91+
svg {
92+
color: #fff;
93+
font-size: 14px;
94+
}
95+
96+
&:hover {
97+
background: rgba(255, 255, 255, 0.15);
98+
}
99+
}
94100
}
95101
}
96102

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

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
33
import './index.less';
44
import {
5+
CaretRightOutlined,
56
CompressOutlined,
67
DownloadOutlined,
78
ExpandOutlined,
89
ExportOutlined,
10+
LoadingOutlined,
11+
PauseOutlined,
912
ThunderboltOutlined,
1013
VideoCameraOutlined,
1114
} from '@ant-design/icons';
@@ -14,6 +17,7 @@ import type {
1417
PlayerRef,
1518
RenderCustomControls,
1619
RenderFullscreenButton,
20+
RenderPlayPauseButton,
1721
} from '@remotion/player';
1822
import { Dropdown, Spin, Switch, Tooltip, message } from 'antd';
1923
import GlobalPerspectiveIcon from '../../icons/global-perspective.svg';
@@ -138,12 +142,26 @@ export function Player(props?: {
138142

139143
const [mouseOverSettingsIcon, setMouseOverSettingsIcon] = useState(false);
140144

145+
const renderPlayPauseButton: RenderPlayPauseButton = useCallback(
146+
({ playing, isBuffering }) => {
147+
if (isBuffering)
148+
return <LoadingOutlined spin style={{ color: '#fff' }} />;
149+
return playing ? (
150+
<PauseOutlined style={{ color: '#fff' }} />
151+
) : (
152+
<CaretRightOutlined style={{ color: '#fff' }} />
153+
);
154+
},
155+
[],
156+
);
157+
141158
const renderFullscreenButton: RenderFullscreenButton = useCallback(
142-
({ isFullscreen }) => (
143-
<div className="status-icon">
144-
{isFullscreen ? <CompressOutlined /> : <ExpandOutlined />}
145-
</div>
146-
),
159+
({ isFullscreen }) =>
160+
isFullscreen ? (
161+
<CompressOutlined style={{ color: '#fff' }} />
162+
) : (
163+
<ExpandOutlined style={{ color: '#fff' }} />
164+
),
147165
[],
148166
);
149167

@@ -161,29 +179,41 @@ export function Player(props?: {
161179
</Tooltip>
162180
) : null}
163181

164-
<Tooltip title={isExporting ? 'Generating...' : 'Export Video'}>
165-
<div
166-
className="status-icon"
167-
onClick={isExporting ? undefined : handleExportVideo}
168-
style={{
169-
opacity: isExporting ? 0.5 : 1,
170-
cursor: isExporting ? 'not-allowed' : 'pointer',
171-
}}
172-
>
173-
{isExporting ? (
174-
<Spin size="small" percent={exportProgress} />
175-
) : (
176-
<ExportOutlined />
177-
)}
178-
</div>
179-
</Tooltip>
180-
181182
<Dropdown
182183
trigger={['hover', 'click']}
183184
placement="topRight"
184185
overlayStyle={{ minWidth: '148px' }}
185186
dropdownRender={() => (
186187
<div className="player-settings-dropdown">
188+
{/* Export video */}
189+
<div
190+
className="player-settings-item"
191+
style={{
192+
display: 'flex',
193+
alignItems: 'center',
194+
gap: '4px',
195+
height: '32px',
196+
padding: '0 8px',
197+
borderRadius: '4px',
198+
cursor: isExporting ? 'not-allowed' : 'pointer',
199+
opacity: isExporting ? 0.5 : 1,
200+
}}
201+
onClick={isExporting ? undefined : handleExportVideo}
202+
>
203+
{isExporting ? (
204+
<Spin size="small" percent={exportProgress} />
205+
) : (
206+
<ExportOutlined style={{ width: '16px', height: '16px' }} />
207+
)}
208+
<span style={{ fontSize: '12px' }}>
209+
{isExporting
210+
? `Exporting ${exportProgress}%`
211+
: 'Export video'}
212+
</span>
213+
</div>
214+
215+
<div className="player-settings-divider" />
216+
187217
{/* Focus on cursor toggle */}
188218
<div
189219
className="player-settings-item"
@@ -345,8 +375,9 @@ export function Player(props?: {
345375
playbackRate={playbackSpeed}
346376
controls
347377
showVolumeControls={false}
348-
renderCustomControls={renderCustomControls}
378+
renderPlayPauseButton={renderPlayPauseButton}
349379
renderFullscreenButton={renderFullscreenButton}
380+
renderCustomControls={renderCustomControls}
350381
autoPlay
351382
loop={false}
352383
style={{

0 commit comments

Comments
 (0)