Skip to content

Commit b5cba7e

Browse files
committed
新增屬性 id,支援指定元件進行替換,增加 destroy 方法,有效減少記憶體洩漏問題。
1 parent 2816a8f commit b5cba7e

File tree

14 files changed

+151
-72
lines changed

14 files changed

+151
-72
lines changed

DEPRECATION.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## 預計 `3.*.*` 棄用
2+
3+
- `type`:棄用,改用 `option: { panelType: xxx }`
4+
- `panel`:棄用,改用 `option: { panelItem: xxx }`
5+
- `volume`:棄用,改用 `option: { volume: xxx }`
6+
- `mute`:棄用,改用 `option: { mute: xxx }`
7+
- `event`:棄用,改用 `when`

README.md

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,46 @@
2727
- **從 CDN 引入**
2828
- **引入 `PDPlayerKit` 套件**
2929
```html
30-
<script src="https://cdn.jsdelivr.net/npm/pdplayerkit@[VERSION]/dist/PDPlayerKit.js"></script>
30+
<script src="https://cdn.jsdelivr.net/npm/pdplayerkit@latest/dist/PDPlayerKit.js"></script>
3131
```
3232
- **Module 版本**
3333
```javascript
34-
import { player as PDPlayer } from "https://cdn.jsdelivr.net/npm/pdplayerkit@[VERSION]/dist/PDPlayerKit.module.js";
34+
import { player as PDPlayer } from "https://cdn.jsdelivr.net/npm/pdplayerkit@latest/dist/PDPlayerKit.module.js";
3535
```
3636
3737
## 使用方法
3838
3939
- **初始化 `editor``viewer`**
4040
```Javascript
4141
const dom = new PDPlayer({
42-
// 選擇播放器風格,例如 "minimal""classic"
43-
type: "[風格選擇]",
42+
// 選填:指定元件替換為播放器(元件的 ID)
43+
// 若未指定,需手動將 dom.body 加入至視圖中
44+
// id: "元件 ID",
4445
45-
// 媒體來源設定:以下個選項中僅能選擇一項
46+
// 必填:媒體來源設定,以下選項中僅能選擇一項
4647
video: "[影片位置]",
4748
// audio: "[音訊位置]",
4849
// vimeo: "[Vimeo ID]",
4950
// youtube: "[YouTube ID]"
5051
51-
// 設定顯示的控制面板選項
52-
panel: [
53-
"play", "progress", "time",
54-
"volume", "volumeMini", "rate", "full"
55-
],
56-
57-
// 播放設置
58-
volume: 100,
59-
mute: false,
60-
61-
// 事件監聽
62-
event: {
52+
// 選填:播放設置
53+
option: {
54+
// 控制面板外觀風格,例如 "minimal""classic"
55+
panelType: "[風格選擇]",
56+
57+
// 控制面板按鈕,依需求選擇顯示的功能
58+
panel: [
59+
"play", "progress", "time", "timeMini",
60+
"volume", "volumeMini", "rate", "full"
61+
],
62+
// 播放器預設音量
63+
volume: 100,
64+
// 播放器預設靜音
65+
mute: false
66+
},
67+
68+
// 選填:事件監聽器,可監聽播放過程中的特定事件
69+
when: {
6370
ready: function () {
6471
console.log("播放器準備完成");
6572
},
@@ -71,11 +78,29 @@
7178
},
7279
end: function () {
7380
console.log("播放結束");
81+
},
82+
destroyed: function () {
83+
console.log("已移除");
7484
}
7585
}
7686
});
7787
88+
// 若無指定元件,需手動將播放器加入至 DOM 中
7889
(...).appendChild(dom.body);
90+
91+
// 更換內容影片
92+
// dom.replace({
93+
// 必填:媒體來源設定,以下選項中僅能選擇一項
94+
// video: "[影片位置]",
95+
// audio: "[音訊位置]",
96+
// vimeo: "[Vimeo ID]",
97+
// youtube: "[YouTube ID]"
98+
// option: {[播放設置]},
99+
// when: {[事件監聽]}
100+
// })
101+
102+
// 移除元件
103+
// dom.destory();
79104
```
80105
81106

dist/PDPlayerKit.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/PDPlayerKit.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/PDPlayerKit.module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)