66 VisibleSprite ,
77 renderTxt2ImgBitmap ,
88} from '@webav/av-cliper' ;
9+ import { Button , Radio } from 'antd' ;
910import {
1011 Timeline ,
1112 TimelineAction ,
@@ -17,14 +18,12 @@ import { assetsPrefix, createFileWriter } from './utils';
1718
1819type TLActionWithName = TimelineAction & { name : string } ;
1920
20- const uhaParam = new URLSearchParams ( location . search ) . get ( 'UHA' ) ;
21- const __unsafe_hardwareAcceleration__ = [
22- 'no-preference' ,
23- 'prefer-hardware' ,
24- 'prefer-software' ,
25- ] . includes ( uhaParam )
26- ? uhaParam
27- : undefined ;
21+ const uhaParam = new URLSearchParams ( location . search ) . get ( 'UHA' ) ?? '' ;
22+ const __unsafe_hardwareAcceleration__ = (
23+ [ 'no-preference' , 'prefer-hardware' , 'prefer-software' ] . includes ( uhaParam )
24+ ? uhaParam
25+ : undefined
26+ ) as HardwarePreference | undefined ;
2827
2928const TimelineEditor = ( {
3029 timelineData : tlData ,
@@ -53,22 +52,22 @@ const TimelineEditor = ({
5352 ) ;
5453 return (
5554 < div className = "" >
56- < div >
55+ < div className = "mb-2" >
5756 < span className = "ml-[10px]" > 缩放:</ span >
58- < button
57+ < Button
5958 onClick = { ( ) => setScale ( scale + 1 ) }
6059 className = "border rounded-full"
6160 >
6261 -
63- </ button >
64- < button
62+ </ Button >
63+ < Button
6564 onClick = { ( ) => setScale ( scale - 1 > 1 ? scale - 1 : 1 ) }
6665 className = "border rounded-full"
6766 >
6867 +
69- </ button >
68+ </ Button >
7069 < span className = "mx-[10px]" > |</ span >
71- < button
70+ < Button
7271 disabled = { activeAction == null }
7372 className = "mx-[10px]"
7473 onClick = { ( ) => {
@@ -77,8 +76,8 @@ const TimelineEditor = ({
7776 } }
7877 >
7978 删除
80- </ button >
81- < button
79+ </ Button >
80+ < Button
8281 disabled = { activeAction == null }
8382 className = "mx-[10px]"
8483 onClick = { ( ) => {
@@ -87,7 +86,7 @@ const TimelineEditor = ({
8786 } }
8887 >
8988 分割
90- </ button >
89+ </ Button >
9190 </ div >
9291 < Timeline
9392 ref = { ( v ) => {
@@ -224,29 +223,18 @@ export default function App() {
224223
225224 return (
226225 < div className = "canvas-wrap" >
227- < div ref = { ( el ) => setCvsWrapEl ( el ) } > </ div >
228- < input
229- type = "radio"
230- id = "clip-source-remote"
231- name = "clip-source"
232- defaultChecked = { clipSource === 'remote' }
233- onChange = { ( ) => {
234- setClipSource ( 'remote' ) ;
226+ < div ref = { ( el ) => setCvsWrapEl ( el ) } className = "mb-2" > </ div >
227+ < Radio . Group
228+ onChange = { ( e ) => {
229+ setClipSource ( e . target . value ) ;
235230 } }
236- />
237- < label htmlFor = "clip-source-remote" > 示例素材</ label >
238- < input
239- type = "radio"
240- id = "clip-source-local"
241- name = "clip-source"
242- defaultChecked = { clipSource === 'local' }
243- onChange = { ( ) => {
244- setClipSource ( 'local' ) ;
245- } }
246- />
247- < label htmlFor = "clip-source-local" > 本地素材</ label >
231+ value = { clipSource }
232+ >
233+ < Radio value = "remote" > 示例素材</ Radio >
234+ < Radio value = "local" > 本地素材</ Radio >
235+ </ Radio . Group >
248236 < span className = "mx-[10px]" > |</ span >
249- < button
237+ < Button
250238 className = "mx-[10px]"
251239 onClick = { async ( ) => {
252240 const stream =
@@ -263,8 +251,8 @@ export default function App() {
263251 } }
264252 >
265253 + 视频
266- </ button >
267- < button
254+ </ Button >
255+ < Button
268256 className = "mx-[10px]"
269257 onClick = { async ( ) => {
270258 const stream =
@@ -277,8 +265,8 @@ export default function App() {
277265 } }
278266 >
279267 + 音频
280- </ button >
281- < button
268+ </ Button >
269+ < Button
282270 className = "mx-[10px]"
283271 onClick = { async ( ) => {
284272 let args ;
@@ -295,14 +283,15 @@ export default function App() {
295283 } else {
296284 args = ( await fetch ( clipsSrc [ 2 ] ) ) . body ! ;
297285 }
286+ // @ts -ignore
298287 const spr = new VisibleSprite ( new ImgClip ( args ) ) ;
299288 await avCvs ?. addSprite ( spr ) ;
300289 addSprite2Track ( '3-img' , spr , '图片' ) ;
301290 } }
302291 >
303292 + 图片
304- </ button >
305- < button
293+ </ Button >
294+ < Button
306295 className = "mx-[10px]"
307296 onClick = { async ( ) => {
308297 const spr = new VisibleSprite (
@@ -318,9 +307,9 @@ export default function App() {
318307 } }
319308 >
320309 + 文字
321- </ button >
310+ </ Button >
322311 < span className = "mx-[10px]" > |</ span >
323- < button
312+ < Button
324313 className = "mx-[10px]"
325314 onClick = { async ( ) => {
326315 if ( avCvs == null || tlState . current == null ) return ;
@@ -332,8 +321,8 @@ export default function App() {
332321 } }
333322 >
334323 { playing ? '暂停' : '播放' }
335- </ button >
336- < button
324+ </ Button >
325+ < Button
337326 className = "mx-[10px]"
338327 onClick = { async ( ) => {
339328 if ( avCvs == null ) return ;
@@ -343,8 +332,8 @@ export default function App() {
343332 } }
344333 >
345334 导出视频
346- </ button >
347- < p > </ p >
335+ </ Button >
336+ < hr className = "m-2" / >
348337 < TimelineEditor
349338 timelineData = { tlData }
350339 timelineState = { tlState }
@@ -381,7 +370,7 @@ export default function App() {
381370 if ( avCvs == null || spr == null || tlState . current == null ) return ;
382371 const newClips = await spr
383372 . getClip ( )
384- . split ( tlState . current . getTime ( ) * 1e6 - spr . time . offset ) ;
373+ . split ?. ( tlState . current . getTime ( ) * 1e6 - spr . time . offset ) ! ;
385374 // 移除原有对象
386375 avCvs . removeSprite ( spr ) ;
387376 actionSpriteMap . delete ( action ) ;
0 commit comments