eplayer 1.6.12 → 1.6.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/eplayer.js CHANGED
@@ -21,7 +21,7 @@ class Eplayer extends HTMLElement {
21
21
  }
22
22
 
23
23
  static get observedAttributes() {
24
- return ['src', 'type', 'danma', 'live','cover']
24
+ return ['src', 'type', 'danma', 'live', 'cover']
25
25
  }
26
26
 
27
27
  attributeChangedCallback(name, oldVal, newVal) {
@@ -53,7 +53,7 @@ class Eplayer extends HTMLElement {
53
53
  if (name === 'cover') {
54
54
  this.cover = newVal
55
55
  this.$('.rotate-img').setAttribute('src', newVal)
56
- this.$('.cover').style.background=`url(${newVal || ''}) center/cover no-repeat #fff`
56
+ this.$('.cover').style.background = `url(${newVal || ''}) center/cover no-repeat #fff`
57
57
  }
58
58
  }
59
59
 
@@ -199,79 +199,6 @@ class Eplayer extends HTMLElement {
199
199
  }
200
200
  }
201
201
 
202
- keydown(e) {
203
- e.preventDefault()
204
- switch (e.keyCode) {
205
- case 37: // 左箭头 - 后退10秒
206
- this.video.currentTime = Math.max(0, this.video.currentTime - 10)
207
- break
208
- case 39: // 右箭头 - 前进10秒 (支持长按3倍速)
209
- if (!this.isRightKeyPressed) {
210
- this.isRightKeyPressed = true
211
- this.rightKeyPressTime = Date.now()
212
- this.originalPlaybackRate = this.video.playbackRate
213
-
214
- // 设置定时器,如果持续按住超过500ms则开启3倍速
215
- this.rightKeyHoldTimer = setTimeout(() => {
216
- this.isSpeedModeActive = true
217
- this.video.playbackRate = 3
218
- this.$('.speed').innerText = '3x'
219
- this.$('.speed-indicator').style.display = 'block'
220
- }, 500)
221
- }
222
- break
223
- case 38: // 上箭头 - 增加音量5%
224
- e.preventDefault()
225
- this.video.volume = Math.min(1, this.video.volume + 0.05)
226
- break
227
- case 40: // 下箭头 - 减少音量5%
228
- e.preventDefault()
229
- this.video.volume = Math.max(0, this.video.volume - 0.05)
230
- break
231
- case 32: // 空格键 - 播放/暂停
232
- e.preventDefault()
233
- this.play()
234
- break
235
- case 77: // M键 - 静音/取消静音
236
- this.volume()
237
- break
238
- default:
239
- }
240
- }
241
-
242
- keyup(e) {
243
- switch (e.keyCode) {
244
- case 39: // 右箭头松开
245
- if (this.isRightKeyPressed) {
246
- const pressDuration = Date.now() - this.rightKeyPressTime
247
- this.isRightKeyPressed = false
248
-
249
- // 清除定时器
250
- if (this.rightKeyHoldTimer) {
251
- clearTimeout(this.rightKeyHoldTimer)
252
- this.rightKeyHoldTimer = null
253
- }
254
-
255
- // 判断是短按还是长按
256
- if (pressDuration < 500 && !this.isSpeedModeActive) {
257
- // 短按:只快进10秒
258
- this.video.currentTime = Math.min(this.video.duration, this.video.currentTime + 10)
259
- } else if (this.isSpeedModeActive) {
260
- // 长按结束:恢复原播放速度并隐藏提示
261
- this.video.playbackRate = this.originalPlaybackRate
262
- this.$('.speed').innerText = this.originalPlaybackRate + 'x'
263
- this.$('.speed-indicator').style.display = 'none'
264
- this.isSpeedModeActive = false
265
- }
266
-
267
- // 重置状态
268
- this.rightKeyPressTime = null
269
- }
270
- break
271
- default:
272
- }
273
- }
274
-
275
202
  ended() {
276
203
  // this.$('.is-play').classList.replace('ep-pause', 'ep-play')
277
204
  }
@@ -632,10 +559,10 @@ class Eplayer extends HTMLElement {
632
559
  </div>
633
560
  <div class="right">
634
561
  <em class="speed">1x</em>
635
- ${this.cover ? `<em class="pip">画中画</em>`:''}
562
+ ${this.cover ? `<em class="pip">画中画</em>` : ''}
636
563
  <iconpark-icon icon-id="volume-ok" size="2rem" class="is-volume"></iconpark-icon>
637
- ${this.cover ? `<iconpark-icon icon-id="web-fullscreen" size="2rem"></iconpark-icon>`:''}
638
- ${this.cover ?`<iconpark-icon icon-id="fullscreen" size="2rem" class="fullscreen"></iconpark-icon>`:""}
564
+ ${this.cover ? `<iconpark-icon icon-id="web-fullscreen" size="2rem"></iconpark-icon>` : ''}
565
+ ${this.cover ? `<iconpark-icon icon-id="fullscreen" size="2rem" class="fullscreen"></iconpark-icon>` : ""}
639
566
  </div>
640
567
  </div>
641
568
  </div>
@@ -686,7 +613,7 @@ class Eplayer extends HTMLElement {
686
613
  connectedCallback() {
687
614
  this.video = this.$('.video')
688
615
  this.video.volume = 0.5
689
- this.danmaku = new Danmaku({
616
+ this.danmaku = Danmaku && new Danmaku({
690
617
  container: this.$('.danmaku')
691
618
  })
692
619
  // setVolume(this.video.volume * 10, this.$('.line'))
@@ -716,23 +643,10 @@ class Eplayer extends HTMLElement {
716
643
  },
717
644
  })
718
645
 
719
- // 使用全局键盘监听以确保按键事件能在任何地方被捕获
720
- this.keydownHandler = this.keydown.bind(this)
721
- this.keyupHandler = this.keyup.bind(this)
722
- document.addEventListener('keydown', this.keydownHandler)
723
- document.addEventListener('keyup', this.keyupHandler)
724
-
725
646
  this.delegate('mousemove', this.alow)
726
647
  }
727
648
 
728
649
  disconnectedCallback() {
729
- // 清理全局键盘事件监听器
730
- if (this.keydownHandler) {
731
- document.removeEventListener('keydown', this.keydownHandler)
732
- }
733
- if (this.keyupHandler) {
734
- document.removeEventListener('keyup', this.keyupHandler)
735
- }
736
650
 
737
651
  // 清理长按定时器和状态
738
652
  if (this.rightKeyHoldTimer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eplayer",
3
- "version": "1.6.12",
3
+ "version": "1.6.14",
4
4
  "description": "A web-components html5 video player facing future",
5
5
  "main": "./docs/eplayer.js",
6
6
  "module": "./docs/eplayer.js",
Binary file