Skip to content

Commit

Permalink
fix: link incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Dec 3, 2023
1 parent 4e5914e commit 5701dfb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
13 changes: 7 additions & 6 deletions doc-site/docs/demo/decode-audio.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { AudioClip, DEFAULT_AUDIO_CONF } from '@webav/av-cliper';
import { Button, Radio } from 'antd';
import React, { useState } from 'react';
import { assetsPrefix } from './utils';

const audios = {
'44.1kHz-2chan.m4a': '/audio/44.1kHz-2chan.m4a',
'44.1kHz-2chan.mp3': '/audio/44.1kHz-2chan.mp3',
'16kHz-1chan.mp3': '/audio/16kHz-1chan.mp3',
};
const audios = assetsPrefix({
'44.1kHz-2chan.m4a': 'audio/44.1kHz-2chan.m4a',
'44.1kHz-2chan.mp3': 'audio/44.1kHz-2chan.mp3',
'16kHz-1chan.mp3': 'audio/16kHz-1chan.mp3',
});

let stopAudio = () => {};
async function start(audioType: keyof typeof audios) {
Expand Down Expand Up @@ -72,7 +73,7 @@ function createUI(start: Function) {
value={value}
>
<Radio value="44.1kHz-2chan.m4a">44.1kHz-2chan.m4a</Radio>
<Radio value="44.1kHz-2chan.m4a">44.1kHz-2chan.m4a</Radio>
<Radio value="44.1kHz-2chan.mp3">44.1kHz-2chan.mp3</Radio>
<Radio value="16kHz-1chan.mp3">16kHz-1chan.mp3</Radio>
</Radio.Group>
</div>
Expand Down
13 changes: 7 additions & 6 deletions doc-site/docs/demo/decode-image.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { decodeImg } from '@webav/av-cliper';
import { Button, Radio } from 'antd';
import React, { useState } from 'react';
import { assetsPrefix } from './utils';

const imgs = {
avif: '/img/animated.avif',
webp: '/img/animated.webp',
png: '/img/animated.png',
gif: '/img/animated.gif',
};
const imgs = assetsPrefix({
avif: 'img/animated.avif',
webp: 'img/animated.webp',
png: 'img/animated.png',
gif: 'img/animated.gif',
});

let stopRender = () => {};
async function start(
Expand Down
9 changes: 5 additions & 4 deletions doc-site/docs/demo/decode-video.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { MP4Clip } from '@webav/av-cliper';
import { Button, Divider, Radio } from 'antd';
import React, { useState } from 'react';
import { assetsPrefix } from './utils';

const videos = {
'bunny.mp4': '/video/bunny-avc.mp4',
'bear.mp4': '/video/bear-vp9.mp4',
};
const videos = assetsPrefix({
'bunny.mp4': 'video/bunny-avc.mp4',
'bear.mp4': 'video/bear-vp9.mp4',
});

async function start(
speed: number,
Expand Down
10 changes: 8 additions & 2 deletions doc-site/docs/demo/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@



export function assetsPrefix(assetsURL: string[]): string[] {
export function assetsPrefix<T extends (string[] | Record<string, string>)>(assetsURL: T): T {
const prefix = process.env.NODE_ENV === 'development' ? '/' : '/WebAV/'
return assetsURL.map(url => `${prefix}${url}`)
if (Array.isArray(assetsURL)) {
return assetsURL.map(url => `${prefix}${url}`) as T
}

return Object.fromEntries(
Object.entries(assetsURL).map(([k, v]) => [k, `${prefix}${v}`])
) as T
}

0 comments on commit 5701dfb

Please sign in to comment.