|
1 |
| -# PDPlayerKit (JavaScript Library) |
| 1 | +<img src="./static/image/logo.png" width=80> |
2 | 2 |
|
3 |
| -> 模組化 JavaScript 媒體播放器<br> |
4 |
| -> 支援 HTML5、YouTube、Vimeo,提供靈活主題與完整控制面板。 |
| 3 | +# FlexPlyr |
5 | 4 |
|
6 |
| - |
7 |
| - |
8 |
| -<br> |
9 |
| -[](https://github.com/pardnchiu/PDPlayerKit) |
10 |
| -[](https://www.npmjs.com/package/pdplayerkit) |
11 |
| -[](https://www.jsdelivr.com/package/npm/pdplayerkit) |
| 5 | +*(Previously known as PDPlayerKit, renamed to FlexPlyr starting from version `2.2.4`)* |
12 | 6 |
|
13 |
| -## 特點 |
| 7 | +> Modular JavaScript Media Player<br> |
| 8 | +> Supports HTML5, YouTube, Vimeo with flexible themes and a complete control panel. |
14 | 9 |
|
15 |
| -### 多媒體播放 |
16 |
| -- 支援多類型:可播放 **HTML5 影片 / 音訊**、**YouTube** 與 **Vimeo**。 |
17 |
| -- 兼容桌面與行動設備,支持 `playsinline` 和 **全螢幕模式** 切換。 |
| 10 | + |
| 11 | + |
| 12 | +<br> |
| 13 | +[](https://www.npmjs.com/package/@pardnchiu/flexplyr) |
| 14 | +[](https://www.npmjs.com/package/@pardnchiu/flexplyr) |
| 15 | +[](https://www.jsdelivr.com/package/npm/@pardnchiu/flexplyr)<br> |
| 16 | +[](https://github.com/pardnchiu/FlexPlyr/blob/main/README.zh.md) |
18 | 17 |
|
19 |
| -### 高度自定義控制面板 |
20 |
| -- 自由定制按鈕:**播放速率調整**、**音量控制**、**進度條** 等功能按需配置。 |
21 |
| -- 提供多種內建主題: (如 Minimal、Classic、Retro、Simple),方便自由選擇。 |
| 18 | +## Features |
22 | 19 |
|
23 |
| -### 輕量與無依賴 |
24 |
| -- 基於 **原生 API** 和 **YouTube / Vimeo API**,無需額外庫,開箱即用。 |
25 |
| -- 完全移除 **PDRenderKit** 的依賴,減少耦合,提升使用便捷性。 |
26 |
| -- 文件體積小於 數 KB,即使在行動設備上也能高效運行。 |
| 20 | +### Multimedia Playback |
| 21 | +- Supports multiple formats: Play **HTML5 video/audio**, **YouTube**, and **Vimeo**. |
| 22 | +- Compatible with desktop and mobile devices, with `playsinline` and **fullscreen mode** toggle support. |
27 | 23 |
|
28 |
| -### 全面的事件監聽 |
29 |
| -- 支持多種事件監聽: (如 ready、playing、pause、end),方便深度擴展。 |
| 24 | +### Highly Customizable Control Panel |
| 25 | +- Customizable buttons: **Playback speed adjustment**, **volume control**, **progress bar**, etc. |
| 26 | +- Multiple built-in themes (e.g., Minimal, Classic, Retro, Simple) for flexible selection. |
30 | 27 |
|
31 |
| -### 多版本支持 |
32 |
| -- 提供 **ESM (ECMAScript Module)** 與 **一般版本**,適用於多種開發環境,靈活集成。 |
| 28 | +### Lightweight and Dependency-Free |
| 29 | +- Built on **native APIs** and **YouTube/Vimeo APIs**, no extra libraries required. |
| 30 | +- Completely removes dependency on **PDRenderKit**, reducing coupling and enhancing usability. |
| 31 | +- Lightweight with a file size of only a few KB, ensuring smooth performance even on mobile devices. |
33 | 32 |
|
34 |
| -### 更直觀的控制按鈕 |
35 |
| -- 按鈕圖示使用 [Google Icons](https://fonts.google.com/icons),清晰、現代,適配各類主題風格。 |
| 33 | +### Comprehensive Event Listening |
| 34 | +- Supports a wide range of events (e.g., ready, playing, pause, end) for seamless extension. |
36 | 35 |
|
37 |
| -### 友善授權 |
38 |
| -- 授權從 **GPL 3.0** 調整為 **MIT**,方便自由使用與修改,適應更多商業或個人項目。 |
| 36 | +### Multi-Version Support |
| 37 | +- Provides **ESM (ECMAScript Module)** and **regular versions**, suitable for various development environments. |
39 | 38 |
|
40 |
| -## 安裝方式 |
| 39 | +### Intuitive Control Buttons |
| 40 | +- Uses [Google Icons](https://fonts.google.com/icons) for button visuals, modern and adaptable to different themes. |
41 | 41 |
|
42 |
| -### 從 npm 安裝 |
| 42 | +### Friendly Licensing |
| 43 | +- License changed from **GPL 3.0** to **MIT**, offering greater flexibility for commercial and personal projects. |
| 44 | + |
| 45 | +## Installation |
| 46 | + |
| 47 | +### Via npm |
43 | 48 | ```bash
|
44 |
| -npm i pdplayerkit |
| 49 | +npm i @pardnchiu/flexplyr |
45 | 50 | ```
|
46 | 51 |
|
47 |
| -### 從 CDN 引入 |
48 |
| -- **引入 `PDPlayerKit` 套件** |
| 52 | +### Via CDN |
| 53 | +- **Import the `FlexPlyr` library** |
49 | 54 | ```html
|
50 |
| - <script src="https://cdn.jsdelivr.net/npm/pdplayerkit@latest/dist/PDPlayerKit.js"></script> |
| 55 | + <!-- Version 2.2.4 and above --> |
| 56 | + <script src="https://cdn.jsdelivr.net/npm/@pardnchiu/flexplyr@[VERSION]/dist/FlexPlyr.js"></script> |
| 57 | + |
| 58 | + <!-- Version 2.2.3 and below --> |
| 59 | + <script src="https://cdn.jsdelivr.net/npm/pdplayerkit@[VERSION]/dist/PDPlayerKit.js"></script> |
51 | 60 | ```
|
52 |
| -- **Module 版本** |
| 61 | +- **Module Version** |
53 | 62 | ```javascript
|
54 |
| - import { player as PDPlayer } from "https://cdn.jsdelivr.net/npm/pdplayerkit@latest/dist/PDPlayerKit.module.js"; |
| 63 | + // Version 2.2.4 and above |
| 64 | + import { FPlyr } from "https://cdn.jsdelivr.net/npm/@pardnchiu/flexplyr@[VERSION]/dist/FlexPlyr.esm.js"; |
| 65 | + |
| 66 | + // Version 2.2.3 and below |
| 67 | + import { player } from "https://cdn.jsdelivr.net/npm/pdplayerkit@[VERSION]/dist/PDPlayerKit.module.js"; |
55 | 68 | ```
|
56 |
| -- **初始化 `editor` 和 `viewer`** |
| 69 | +- **Initialize `FPlyr`** |
57 | 70 | ```Javascript
|
58 |
| - const dom = new PDPlayer({ |
59 |
| - // 選填:指定元件替換為播放器(元件的 ID) |
60 |
| - // 若未指定,需手動將 dom.body 加入至視圖中 |
61 |
| - // id: "元件 ID", |
62 |
| - |
63 |
| - |
64 |
| - // 必填:媒體來源設定,以下選項中僅能選擇一項 |
65 |
| - video: "[影片位置]", |
66 |
| - // audio: "[音訊位置]", |
| 71 | + // Version 2.2.4 and above |
| 72 | + // Unified: FPlyr |
| 73 | + |
| 74 | + // Version 2.2.3 and below |
| 75 | + // IIFE: PDPlayer |
| 76 | + // ESM: player |
| 77 | + |
| 78 | + const dom = new FPlyr({ |
| 79 | + // Optional: Specify the element to replace with the player (element ID) |
| 80 | + // If not specified, manually append dom.body to the view |
| 81 | + // id: "element ID", |
| 82 | + |
| 83 | + // Required: Media source configuration, choose one of the options below |
| 84 | + video: "[video source]", |
| 85 | + // audio: "[audio source]", |
67 | 86 | // vimeo: "[Vimeo ID]",
|
68 | 87 | // youtube: "[YouTube ID]"
|
69 | 88 |
|
70 |
| - // 選填:播放設置 |
| 89 | + // Optional: Playback settings |
71 | 90 | option: {
|
72 |
| - // 是否顯示滑桿,預設 true |
| 91 | + // Whether to show the slider, default is true |
73 | 92 | showThumb: true,
|
74 | 93 |
|
75 |
| - // 控制面板外觀風格,例如 "minimal" 或 "classic" |
76 |
| - panelType: "[風格選擇]", |
| 94 | + // Control panel style, e.g., "minimal" or "classic" |
| 95 | + panelType: "[style choice]", |
77 | 96 |
|
78 |
| - // 控制面板按鈕,依需求選擇顯示的功能 |
| 97 | + // Control panel buttons, choose functions to display |
79 | 98 | panel: [
|
80 | 99 | "play", "progress", "time", "timeMini",
|
81 | 100 | "volume", "volumeMini", "rate", "full"
|
82 | 101 | ],
|
83 |
| - // 播放器預設音量 |
| 102 | + // Default volume level |
84 | 103 | volume: 100,
|
85 |
| - // 播放器預設靜音 |
| 104 | + // Default mute setting |
86 | 105 | mute: false
|
87 | 106 | },
|
88 | 107 |
|
89 |
| - // 選填:事件監聽器,可監聽播放過程中的特定事件 |
| 108 | + // Optional: Event listeners to monitor specific events during playback |
90 | 109 | when: {
|
91 | 110 | ready: function () {
|
92 |
| - console.log("播放器準備完成"); |
| 111 | + console.log("Player is ready"); |
93 | 112 | },
|
94 | 113 | playing: function () {
|
95 |
| - console.log("播放中"); |
| 114 | + console.log("Playing"); |
96 | 115 | },
|
97 | 116 | pause: function () {
|
98 |
| - console.log("暫停"); |
| 117 | + console.log("Paused"); |
99 | 118 | },
|
100 | 119 | end: function () {
|
101 |
| - console.log("播放結束"); |
| 120 | + console.log("Playback ended"); |
102 | 121 | },
|
103 | 122 | destroyed: function () {
|
104 |
| - console.log("已移除"); |
| 123 | + console.log("Player removed"); |
105 | 124 | }
|
106 | 125 | }
|
107 | 126 | });
|
108 | 127 |
|
109 |
| - // 若無指定元件,需手動將播放器加入至 DOM 中 |
| 128 | + // If no element is specified, manually append the player to the DOM |
110 | 129 | (...).appendChild(dom.body);
|
111 | 130 |
|
112 |
| - // 移除元件 |
113 |
| - // dom.destory(); |
| 131 | + // Remove the component |
| 132 | + // dom.destroy(); |
114 | 133 | ```
|
115 | 134 |
|
116 | 135 |
|
117 |
| -## 開發者 |
| 136 | +## Creator |
118 | 137 |
|
119 | 138 | <img src="https://avatars.githubusercontent.com/u/25631760" align="left" width="96" height="96" style="margin-right: 0.5rem;" />
|
120 | 139 |
|
121 | 140 | <h4 style="padding-top: 0">邱敬幃 Pardn Chiu</h4>
|
122 | 141 |
|
123 | 142 | [](mailto:dev@pardn.io) [](https://linkedin.com/in/pardnchiu)
|
124 | 143 |
|
125 |
| -## 授權條款 |
| 144 | +## License |
126 | 145 |
|
127 |
| -本專案依據 [MIT](https://github.com/pardnchiu/PDPlayerKit/blob/main/LICENSE) 授權使用。 |
| 146 | +This project is licensed under the [MIT License](https://github.com/pardnchiu/FlexPlyr/blob/main/LICENSE). |
128 | 147 |
|
129 | 148 | ***
|
130 | 149 |
|
|
0 commit comments