|
1 | 1 | # PDPlayerKit (JavaScript Library)
|
2 | 2 |
|
3 |
| -> PDPlayerKit 是一個輕量級的 JavaScript 播放器庫,提供嵌入式的 HTML5 影片播放器和 YouTube 播放器,具備高度自定義的控制面板和視覺效果。<br> |
4 |
| -> PDPlayerKit is a lightweight JavaScript library that provides embedded HTML5 video players and YouTube players, featuring highly customizable control panels and visual effects. |
5 |
| -
|
6 |
| -    |
7 |
| - |
8 |
| -## 特點 / Feature |
9 |
| - |
10 |
| -- 支援 HTML5 視頻和 YouTube 視頻播放,<br> |
11 |
| - Supports HTML5 video and YouTube video playback. |
12 |
| - |
13 |
| -- 自定義控制面板,包括播放、暫停、音量控制、播放速率調整等功能。<br> |
14 |
| - Customizable control panel, including play, pause, volume control, playback speed adjustment, and more. |
15 |
| - |
16 |
| -- 支援行動裝置 `playsinline` 的狀態下支援全螢幕播放。<br> |
17 |
| - Supports fullscreen playback on mobile devices when `playsinline` is enabled. |
18 |
| - |
19 |
| -- 使用純 JavaScript / CSS 開發。<br> |
20 |
| - Built using pure JavaScript and CSS. |
21 |
| - |
22 |
| -- 使用 [PDExtension-js](https://github.com/pardnchiu/PDExtension-js) 進行渲染。<br> |
23 |
| - Rendered using [PDExtension-js](https://github.com/pardnchiu/PDExtension-js). |
24 |
| - |
25 |
| -- 使用 [Font Awesome 6](https://fontawesome.com/v6/search) 圖標。<br> |
26 |
| - Use [Font Awesome 6](https://fontawesome.com/v6/search) icons. |
27 |
| - |
28 |
| -- 使用 [iframe-api](https://www.youtube.com/iframe_api) 進行 Youtube 操作。<br> |
29 |
| - YouTube operations are handled via the [iframe-api](https://www.youtube.com/iframe_api). |
30 |
| - |
31 |
| -- 可在 [此處](https://pardnchiu.github.io/PDPlayerKit) 預覽。<br> |
32 |
| - Preview available [Here](https://pardnchiu.github.io/PDPlayerKit). |
33 |
| - |
34 |
| -## 開發者 / Creator |
35 |
| - |
36 |
| -<a href="https://pardn.io"> |
37 |
| -<img src=https://pardn.io/image/head-s.jpg align=left width=100 height=100> |
38 |
| -</a> |
39 |
| - |
40 |
| -### Pardn Chiu 邱敬幃 |
41 |
| - |
42 |
| -[](mailto:mail@pardn.ltd) [](https://linkedin.com/in/pardnchiu) |
43 |
| - |
44 |
| -## 授權 / License |
45 |
| - |
46 |
| -此源代碼項目採用 [GPL-3.0](https://github.com/pardnchiu/PDPlayerKit/blob/main/LICENSE) 許可證授權。<br> |
47 |
| -This source code project is licensed under the [GPL-3.0](https://github.com/pardnchiu/PDPlayerKit/blob/main/LICENSE) license. |
48 |
| - |
49 |
| -## 下載 / Download |
50 |
| - |
51 |
| -```Shell |
52 |
| -npm i pdplayerkit |
53 |
| -``` |
54 |
| - |
55 |
| -## 如何使用 / How to use |
56 |
| - |
57 |
| -- 添加依賴 `PDExtension-js` |
58 |
| -```Html |
59 |
| -<script src="https://cdn.jsdelivr.net/gh/pardnchiu/PDExtension-js@[VERSION]/dist/PDExtension.min.js" copyright="Pardn Ltd"></script> |
60 |
| -``` |
61 |
| - |
62 |
| -- 導入 `player` |
63 |
| -```Javascript |
64 |
| -import { player } from "https://cdn.jsdelivr.net/gh/pardnchiu/PDPlayerKit@[VERSION]/dist/PDPlayerKit.js"; |
65 |
| - |
66 |
| -const elm = new player({ |
67 |
| - videoId: "" // YouTube 視頻 ID |
68 |
| - src: "/static/image/sample.mp4", // 影片連結(適用於 HTML5 影片) |
69 |
| - volume: 100, // 預設音量 |
70 |
| - mute: false, // 預設靜音 |
71 |
| - panel: [ |
72 |
| - "play", //播放鍵 |
73 |
| - "timebar", //進度條 |
74 |
| - "time", //進度時間 |
75 |
| - "mute", //靜音鍵 |
76 |
| - "volume", //音量鍵 |
77 |
| - "rate", //速率鍵 |
78 |
| - "full", //影片 |
79 |
| - ], |
80 |
| - event: { |
81 |
| - ready: function() { |
82 |
| - console.log("ready"); |
83 |
| - }, |
84 |
| - playing: function() { |
85 |
| - console.log("playing"); |
86 |
| - }, |
87 |
| - pause: function() { |
88 |
| - console.log("pause"); |
89 |
| - }, |
90 |
| - end: function() { |
91 |
| - console.log("end"); |
| 3 | +> PDPlayerKit 是一個模組化的 JavaScript 播放器,支持嵌入式 HTML5、YouTube 和 Vimeo 播放器,具備高度自定義的控制面板、風格主題,並支援多媒體格式。 |
| 4 | +
|
| 5 | +  <br> |
| 6 | +[](https://github.com/pardnchiu/PDPlayerKit) [](https://www.npmjs.com/package/pdplayerkit)  |
| 7 | + |
| 8 | +## 特點 |
| 9 | + |
| 10 | +- 多媒體支持:支持 HTML5 影片、YouTube 和 Vimeo 播放,音訊播放功能也已新增。 |
| 11 | +- 自定義控制面板:包括播放、暫停、音量調節、播放速率調整等功能,並提供多種風格主題選擇。 |
| 12 | +- 多風格主題:內建多種預設風格,使用者可依據需求自由切換(如 Minimal、Classic、Retro、Simple 等)。 |
| 13 | +- 多種版本支持:提供 ESM 和普通版本,方便用於不同開發環境。 |
| 14 | +- 無依賴:已排除 PDRenderKit 的依賴。 |
| 15 | +- 授權從 GPL 3.0 改為 MIT |
| 16 | +- 使用 [Google Icons](https://fonts.google.com/icons) 圖示黨做按鈕。 |
| 17 | +- 使用 [pixabay.com](https://pixabay.com/videos/) 影音資源做範例。 |
| 18 | +- 可在 [此處](https://pardnchiu.github.io/PDPlayerKit) 預覽。 |
| 19 | + |
| 20 | +## 安裝方式 |
| 21 | + |
| 22 | +- **從 npm 安裝** |
| 23 | + ```bash |
| 24 | + npm i pdplayerkit |
| 25 | + ``` |
| 26 | + |
| 27 | +- **從 CDN 引入** |
| 28 | + - **引入 `PDPlayerKit` 套件** |
| 29 | + ```html |
| 30 | + <script src="https://cdn.jsdelivr.net/npm/pdplayerkit@[VERSION]/dist/PDPlayerKit.js"></script> |
| 31 | + ``` |
| 32 | + - **Module 版本** |
| 33 | + ```javascript |
| 34 | + import { player as PDPlayer } from "https://cdn.jsdelivr.net/npm/pdplayerkit@[VERSION]/dist/PDPlayerKit.module.js"; |
| 35 | + ``` |
| 36 | +
|
| 37 | +## 使用方法 |
| 38 | +
|
| 39 | +- **初始化 `editor` 和 `viewer`** |
| 40 | + ```Javascript |
| 41 | + const dom = new PDPlayer({ |
| 42 | + // 選擇播放器風格,例如 "minimal" 或 "classic" |
| 43 | + type: "[風格選擇]", |
| 44 | +
|
| 45 | + // 媒體來源設定:以下個選項中僅能選擇一項 |
| 46 | + video: "[影片位置]", |
| 47 | + // audio: "[音訊位置]", |
| 48 | + // vimeo: "[Vimeo ID]", |
| 49 | + // youtube: "[YouTube ID]" |
| 50 | +
|
| 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: { |
| 63 | + ready: function () { |
| 64 | + console.log("播放器準備完成"); |
| 65 | + }, |
| 66 | + playing: function () { |
| 67 | + console.log("播放中"); |
| 68 | + }, |
| 69 | + pause: function () { |
| 70 | + console.log("暫停"); |
| 71 | + }, |
| 72 | + end: function () { |
| 73 | + console.log("播放結束"); |
| 74 | + } |
92 | 75 | }
|
93 |
| - } |
94 |
| -}); |
| 76 | + }); |
95 | 77 |
|
96 |
| -[DOM].appendChild(elm.body); |
97 |
| -``` |
98 |
| -*** |
| 78 | + (...).appendChild(dom.body); |
| 79 | + ``` |
| 80 | +
|
| 81 | +
|
| 82 | +## 開發者 |
| 83 | +
|
| 84 | +<img src="https://avatars.githubusercontent.com/u/25631760" align="left" width="96" height="96" style="margin-right: 0.5rem;" /> |
| 85 | +
|
| 86 | +<h4 style="padding-top: 0">邱敬幃 Pardn Chiu</h4> |
| 87 | +
|
| 88 | +[](mailto:dev@pardn.io) [](https://linkedin.com/in/pardnchiu) |
| 89 | +
|
| 90 | +## 授權條款 |
99 | 91 |
|
100 |
| -*翻譯皆靠 ChatGPT* |
| 92 | +本專案依據 [MIT](https://github.com/pardnchiu/PDPlayerKit/blob/main/LICENSE) 授權使用。 |
101 | 93 |
|
102 | 94 | ***
|
103 | 95 |
|
104 |
| -©️ 2023 [Pardn Chiu 邱敬幃](https://www.linkedin.com/in/pardnchiu) |
| 96 | +©️ 2023 [邱敬幃 Pardn Chiu](https://www.linkedin.com/in/pardnchiu) |
0 commit comments