eplayer 1.6.4 → 1.6.7

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.
Files changed (2) hide show
  1. package/docs/eplayer.js +18 -35
  2. package/package.json +1 -1
package/docs/eplayer.js CHANGED
@@ -6,6 +6,7 @@ class Eplayer extends HTMLElement {
6
6
  this.type = this.getAttribute('type')
7
7
  this.live = JSON.parse(this.getAttribute('live'))
8
8
  this.danmaku = null
9
+ this.subs = []
9
10
 
10
11
  this.init()
11
12
  this.stream()
@@ -82,10 +83,12 @@ class Eplayer extends HTMLElement {
82
83
  this.video.play()
83
84
  this.danmaku.resume()
84
85
  this.$('.is-play').setAttribute('icon-id', 'pause')
86
+ this.emit('play')
85
87
  } else {
86
88
  this.video.pause()
87
89
  this.danmaku.pause()
88
90
  this.$('.is-play').setAttribute('icon-id', 'play')
91
+ this.emit('pause')
89
92
  }
90
93
  }
91
94
 
@@ -140,11 +143,11 @@ class Eplayer extends HTMLElement {
140
143
  }
141
144
 
142
145
  alow() {
143
- console.log(111)
144
146
  clearTimeout(this.timer)
145
147
  this.$('.mark').style.cursor = 'default'
148
+ this.$('.eplayer').classList.add('hover')
146
149
  this.timer = setTimeout(() => {
147
- this.$('.controls').style.bottom = -34 + 'px'
150
+ this.$('.eplayer').classList.remove('hover')
148
151
  this.$('.mark').style.cursor = 'none'
149
152
  }, 5000)
150
153
  }
@@ -226,7 +229,7 @@ class Eplayer extends HTMLElement {
226
229
  }
227
230
 
228
231
  speed(e) {
229
- this.video.playbackRate === 2 ? (this.video.playbackRate = 1) : (this.video.playbackRate = this.video.playbackRate + 0.5)
232
+ this.video.playbackRate === 3 ? (this.video.playbackRate = 1) : (this.video.playbackRate = this.video.playbackRate + 0.25)
230
233
  this.$('.speed').innerText = this.video.playbackRate + 'x'
231
234
  }
232
235
 
@@ -264,12 +267,9 @@ class Eplayer extends HTMLElement {
264
267
  bottom:-34px;
265
268
  z-index:1;
266
269
  }
267
- .eplayer:hover .controls{
270
+ .hover:hover .controls{
268
271
  bottom:0;
269
- animation: hidden 0s ease-in 5s forwards;
270
- animation-fill-mode: forwards;
271
- transition: .3s ease-out;
272
- }
272
+ }
273
273
  .progress{
274
274
  display:${this.live ? 'none' : 'block'};
275
275
  position:relative;
@@ -334,13 +334,6 @@ class Eplayer extends HTMLElement {
334
334
  transform: translate(50%,0);
335
335
  cursor:pointer;
336
336
  z-index:1;
337
- }
338
- @keyframes hidden {
339
- to {
340
-
341
- transition: .3s ease-out;
342
- bottom:-34px;
343
- }
344
337
  }
345
338
  @keyframes loading{
346
339
  0%{
@@ -423,7 +416,7 @@ class Eplayer extends HTMLElement {
423
416
 
424
417
  </style>
425
418
 
426
- <div class="eplayer">
419
+ <div class="eplayer hover">
427
420
  <div class="danmaku"></div>
428
421
  <video id="video" class="video" src="${this.src || ''}"></video>
429
422
  <div class="mark loading"></div>
@@ -451,7 +444,6 @@ class Eplayer extends HTMLElement {
451
444
  </div>
452
445
  </div>
453
446
  </div>
454
- <iconpark-icon icon-id="play"></iconpark-icon>
455
447
  <div class="panel"></div>
456
448
  </div>
457
449
  `
@@ -490,16 +482,6 @@ class Eplayer extends HTMLElement {
490
482
  let dom = this.shadowRoot.querySelectorAll(key)
491
483
  this.doms[key] = dom.length > 1 ? [...dom] : dom[0]
492
484
  }
493
-
494
-
495
- for (const name in Eplayer.plugins) {
496
- const cb = Eplayer.plugins[name]
497
- let node = document.createElement('li')
498
- node.innerText = name
499
- let panel = this.$('.panel')
500
- panel.appendChild(node)
501
- node.addEventListener('click', () => cb(this.shadowRoot))
502
- }
503
485
  }
504
486
 
505
487
  connectedCallback() {
@@ -534,8 +516,7 @@ class Eplayer extends HTMLElement {
534
516
  },
535
517
  })
536
518
  this.delegate('keydown', this.keydown)
537
- this.delegate('mouseleave', this.alow)
538
- this.$('.eplayer').oncontextmenu = () => false
519
+ this.delegate('mousemove', this.alow)
539
520
  }
540
521
 
541
522
  delegate(type, map) {
@@ -557,14 +538,20 @@ class Eplayer extends HTMLElement {
557
538
  }
558
539
  }
559
540
 
541
+ emit (name) {
542
+ const fn = Eplayer.subs[name]
543
+ fn && fn.call(this, this.shadowRoot)
544
+ }
545
+
560
546
  }
561
547
 
562
- Eplayer.plugins = {}
548
+ Eplayer.subs = {}
563
549
 
564
550
  Eplayer.use = function (name, cb) {
565
- this.plugins[name] = cb
551
+ this.subs[name] = cb
566
552
  }
567
553
 
554
+
568
555
  function getTimeStr(time) {
569
556
  let h = Math.floor(time / 3600)
570
557
  let m = Math.floor((time % 3600) / 60)
@@ -585,8 +572,4 @@ function isFullScreen() {
585
572
  document.head.appendChild(link)
586
573
  })()
587
574
 
588
- Eplayer.use('github源码', (ep) => {
589
- window.location.href = 'https://github.com/132yse/eplayer'
590
- })
591
-
592
575
  customElements.define('e-player', Eplayer)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eplayer",
3
- "version": "1.6.4",
3
+ "version": "1.6.7",
4
4
  "description": "A web-components html5 video player facing future",
5
5
  "main": "./docs/eplayer.js",
6
6
  "module": "./docs/eplayer.js",