Skip to content

Commit

Permalink
ts 类型校验
Browse files Browse the repository at this point in the history
  • Loading branch information
xujiujiu authored Mar 1, 2023
1 parent e1fef4d commit 4ff20b8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ const rrwebScriptPath = path.resolve(
const rrwebStylePath = path.resolve(rrwebScriptPath, "../style.css");
const rrwebRaw = fs.readFileSync(rrwebScriptPath, "utf-8");
const rrwebStyle = fs.readFileSync(rrwebStylePath, "utf-8");
interface Config {
// start playback delay time
startDelayTime?: number,
}

function getHtml(
events: Array<eventWithTime>,
config?: Omit<RRwebPlayerOptions["props"], "events">
config?: Omit<RRwebPlayerOptions["props"] & Config, "events">
): string {
return `
<html>
Expand All @@ -38,20 +42,19 @@ function getHtml(
props: {
events,
showController: false,
autoPlay: false, // 默认关闭自动播放
autoPlay: false, // autoPlay off by default
...userConfig
},
});
window.replayer.addEventListener('finish', () => window.onReplayFinish());
let time = userConfig.startDelayTime || 1000 // 开始播放延迟时间
let time = userConfig.startDelayTime || 1000 // start playback delay time, default 1000ms
let start = fn => {
let timer = setTimeout(() => {
clearTimeout(timer);
setTimeout(() => {
fn()
}, time)
}
// 建议默认不自动播放,如果倍速的话自动播放前期页面块会空白
// It is recommended not to play auto by default. If the speed is not 1, the page block in the early stage of autoPlay will be blank
if (userConfig.autoPlay) {
start = fn => {
fn()
Expand All @@ -73,7 +76,7 @@ type RRvideoConfig = {
input: string;
cb: (file: string, error: null | Error) => void;
output: string;
rrwebPlayer: Omit<RRwebPlayerOptions["props"], "events">;
rrwebPlayer: Omit<RRwebPlayerOptions["props"] & Config, "events">;
};

const defaultConfig: RRvideoConfig = {
Expand Down

0 comments on commit 4ff20b8

Please sign in to comment.