Skip to content

Commit

Permalink
新增 iconsText 参数
Browse files Browse the repository at this point in the history
  • Loading branch information
xiejay97 committed Sep 23, 2024
1 parent 62b85c5 commit 7ac1984
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 21 deletions.
25 changes: 25 additions & 0 deletions d.ts/jessibuca.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,31 @@ declare namespace Jessibuca {
/** 是否显示录制按 */
record?: boolean;
};
/**
* 配置 icon 文字提示
*/
iconsText?: {
/** 播放 */
play?: string;
/** 暂停 */
pause?: string;
/** 声音调节 */
audio?: string;
/** 静音 */
mute?: string;
/** 截图 */
screenshot?: string;
/** 加载 */
loading?: string;
/** 全屏 */
fullscreen?: string;
/** 退出全屏 */
fullscreenExit?: string;
/** 录制 */
record?: string;
/** 停止录制 */
recordStop?: string;
};
/**
* 开启屏幕常亮,在手机浏览器上, canvas标签渲染视频并不会像video标签那样保持屏幕常亮
*/
Expand Down
25 changes: 25 additions & 0 deletions demo/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,31 @@ worker地址
4. audio 是否显示声音按钮
5. record 是否显示录制按钮


### iconsText

- **类型**`object`
- **默认值**`{}`
- **用法**: 配置 icon 文字提示

数据结构如下。

```
{
play: '播放',
pause: '暂停',
audio: '',
mute: '',
screenshot: '截图',
loading: '加载',
fullscreen: '全屏',
fullscreenExit: '退出全屏',
record: '录制',
recordStop: '停止录制',
}
```

### keepScreenOn

- **类型**`boolean`
Expand Down
Binary file modified demo/public/dist.zip
Binary file not shown.
20 changes: 12 additions & 8 deletions demo/public/jessibuca.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/decoder.js

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions dist/jessibuca.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,31 @@ declare namespace Jessibuca {
/** 是否显示录制按 */
record?: boolean;
};
/**
* 配置 icon 文字提示
*/
iconsText?: {
/** 播放 */
play?: string;
/** 暂停 */
pause?: string;
/** 声音调节 */
audio?: string;
/** 静音 */
mute?: string;
/** 截图 */
screenshot?: string;
/** 加载 */
loading?: string;
/** 全屏 */
fullscreen?: string;
/** 退出全屏 */
fullscreenExit?: string;
/** 录制 */
record?: string;
/** 停止录制 */
recordStop?: string;
};
/**
* 开启屏幕常亮,在手机浏览器上, canvas标签渲染视频并不会像video标签那样保持屏幕常亮
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/jessibuca.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/constant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const DEFAULT_PLAYER_OPTIONS = {
audio: false,
record: false,
},
iconsText: {},
controlAutoHide: false, // control auto hide
hasControl: false,
loadingText: '', // loading Text
Expand Down
19 changes: 11 additions & 8 deletions src/control/icons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const iconsMap = {
const DEFAULT_ICONS = {
play: '播放',
pause: '暂停',
audio: '',
Expand All @@ -11,10 +11,13 @@ const iconsMap = {
recordStop: '停止录制',
}

export default Object.keys(iconsMap).reduce((icons, key) => {
icons[key] = `
<i class="jessibuca-icon jessibuca-icon-${key}"></i>
${iconsMap[key] ? `<span class="icon-title-tips"><span class="icon-title">${iconsMap[key]}</span></span>` : ''}
`;
return icons;
}, {});
export default function (iconsText) {
const iconsMap = Object.assign({}, DEFAULT_ICONS, iconsText)
return Object.keys(iconsMap).reduce((icons, key) => {
icons[key] = `
<i class="jessibuca-icon jessibuca-icon-${key}"></i>
${iconsMap[key] ? `<span class="icon-title-tips"><span class="icon-title">${iconsMap[key]}</span></span>` : ''}
`;
return icons;
}, {})
};
6 changes: 3 additions & 3 deletions src/control/template.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import icons from './icons';
import createIcons from './icons';

export default (player, control) => {

Expand All @@ -10,7 +10,7 @@ export default (player, control) => {
}
const options = player._opt;
const operateBtns = options.operateBtns;

const icons = createIcons(options.iconsText)

player.$container.insertAdjacentHTML(
'beforeend',
Expand All @@ -27,7 +27,7 @@ export default (player, control) => {
<div class="jessibuca-recording-time">00:00:01</div>
<div class="jessibuca-icon-recordStop jessibuca-recording-stop">${icons.recordStop}</div>
</div>
`:''}
`: ''}
${options.hasControl ? `
<div class="jessibuca-controls">
<div class="jessibuca-controls-bottom">
Expand Down

0 comments on commit 7ac1984

Please sign in to comment.