eplayer 1.5.1 → 1.5.3

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
@@ -138,13 +138,13 @@ class Eplayer extends HTMLElement {
138
138
  case 38:
139
139
  try {
140
140
  this.video.volume = parseInt(this.video.volume * 100) / 100 + 0.05
141
- } catch (e) {}
141
+ } catch (e) { }
142
142
  setVolume(this.video.volume.toFixed(1) * 10, this.$('.line'))
143
143
  break
144
144
  case 40:
145
145
  try {
146
146
  this.video.volume = parseInt(this.video.volume * 100) / 100 - 0.05
147
- } catch (e) {}
147
+ } catch (e) { }
148
148
  setVolume(this.video.volume.toFixed(1) * 10, this.$('.line'))
149
149
  break
150
150
  case 32:
@@ -210,7 +210,7 @@ class Eplayer extends HTMLElement {
210
210
  init() {
211
211
  let html = `
212
212
  <style>
213
- @import "https://at.alicdn.com/t/font_836948_uhdb83b0e3m.css";
213
+ @import "https://at.alicdn.com/t/font_836948_g9fk6jqpl8l.css";
214
214
  *{
215
215
  padding:0;
216
216
  margin:0;
@@ -272,10 +272,11 @@ class Eplayer extends HTMLElement {
272
272
  }
273
273
  .lines{
274
274
  padding:0 10px;
275
+ display:flex;
276
+ align-items: center;
275
277
  }
276
278
  .line{
277
- padding:0;
278
- margin-bottom: -2px;
279
+ padding:0 2px;
279
280
  cursor:pointer
280
281
  }
281
282
  .line i{
@@ -450,6 +451,7 @@ class Eplayer extends HTMLElement {
450
451
  <i class="epicon ep-speed">
451
452
  <b class="speed">1x</b>
452
453
  </i>
454
+ ${document.pictureInPictureEnabled && `<i class="epicon ep-pip"></i>`}
453
455
  <i class="epicon ep-full"></i>
454
456
  </div>
455
457
  </div>
@@ -489,6 +491,7 @@ class Eplayer extends HTMLElement {
489
491
  '.ep-full',
490
492
  '.panel',
491
493
  '.speed',
494
+ '.pip',
492
495
  ]
493
496
 
494
497
  for (const key of doms) {
@@ -518,6 +521,14 @@ class Eplayer extends HTMLElement {
518
521
  }
519
522
  }
520
523
 
524
+ pip(e) {
525
+ if (!document.pictureInPictureElement) {
526
+ this.video.requestPictureInPicture()
527
+ } else {
528
+ document.exitPictureInPicture()
529
+ }
530
+ }
531
+
521
532
  mount() {
522
533
  this.video = this.$('.video')
523
534
  this.video.volume = 0.5
@@ -535,6 +546,7 @@ class Eplayer extends HTMLElement {
535
546
  '.speed': this.speed,
536
547
  '.bg': this.progress,
537
548
  '.buffer': this.progress,
549
+ '.ep-pip': this.pip,
538
550
  })
539
551
  this.delegate('mousedown', {
540
552
  '.cycle': this.down,
@@ -554,7 +566,7 @@ class Eplayer extends HTMLElement {
554
566
  setVolume(index + 1, this.$('.line'))
555
567
  }
556
568
  })
557
- document.oncontextmenu = () => false
569
+ this.$('.eplayer').oncontextmenu = () => false
558
570
  }
559
571
  }
560
572
 
@@ -587,9 +599,9 @@ function isFullScreen() {
587
599
  return document.isFullScreen || document.webkitIsFullScreen || document.mozIsFullScreen
588
600
  }
589
601
 
590
- ;(function () {
602
+ ; (function () {
591
603
  let link = document.createElement('link')
592
- link.setAttribute('href', 'https://at.alicdn.com/t/font_836948_uhdb83b0e3m.css')
604
+ link.setAttribute('href', 'https://at.alicdn.com/t/font_836948_g9fk6jqpl8l.css')
593
605
  link.setAttribute('rel', 'stylesheet')
594
606
  document.head.appendChild(link)
595
607
  })()
package/docs/index.html CHANGED
@@ -98,7 +98,7 @@
98
98
  </style>
99
99
  <div class="wrapper">
100
100
  <e-player id="ep"
101
- src="https://gss3.baidu.com/6LZ0ej3k1Qd3ote6lo7D0j9wehsv/tieba-smallvideo/3_d97abb65fc36a1d689efd3a105bebce1.mp4">
101
+ src="https://bos.nj.bpc.baidu.com/tieba-movideo/347573243_f2740215c9863213a9f272b81aab1b90_8b216f814f25.mp4">
102
102
  </e-player>
103
103
  <a href="https://github.com/132yse/eplayer">github</a>
104
104
  <a href="https://github.com/132yse/eplayer/blob/master/README.md">README</a>
@@ -110,4 +110,4 @@
110
110
  <script src="./pic.js"></script>
111
111
  </body>
112
112
 
113
- </html>
113
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eplayer",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "A web-components html5 video player facing future",
5
5
  "main": "./packages/eplayer/index.js",
6
6
  "module": "./packages/eplayer/index.js",
@@ -159,18 +159,11 @@ export default class Eplayer extends HTMLElement {
159
159
  }
160
160
 
161
161
  full() {
162
+ let el = this.$('.eplayer')
162
163
  if (isFullScreen()) {
163
- if (document.exitFullscreen) {
164
- document.exitFullscreen()
165
- } else if (document.mozCancelFullScreen) {
166
- document.mozCancelFullScreen()
167
- } else if (document.webkitCancelFullScreen) {
168
- document.webkitCancelFullScreen()
169
- } else if (document.msExitFullscreen) {
170
- document.msExitFullscreen()
171
- }
164
+ const efs = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen
165
+ return efs()
172
166
  } else {
173
- let el = this.$('.eplayer')
174
167
  let rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen
175
168
  return rfs.call(el)
176
169
  }
@@ -210,7 +203,7 @@ export default class Eplayer extends HTMLElement {
210
203
  init() {
211
204
  let html = `
212
205
  <style>
213
- @import "https://at.alicdn.com/t/font_836948_uhdb83b0e3m.css";
206
+ @import "https://at.alicdn.com/t/font_836948_g9fk6jqpl8l.css";
214
207
  *{
215
208
  padding:0;
216
209
  margin:0;
@@ -272,15 +265,15 @@ export default class Eplayer extends HTMLElement {
272
265
  }
273
266
  .lines{
274
267
  padding:0 10px;
268
+ display:flex;
269
+ align-items: center;
275
270
  }
276
271
  .line{
277
- padding:0;
278
- margin-bottom: -2px;
272
+ padding:0 0.1rem;
279
273
  cursor:pointer
280
274
  }
281
275
  .line i{
282
276
  width:4px;
283
- border-radius:4px;
284
277
  display: inline-block;
285
278
  background: var(--icons,rgba(255,255,255,0.6));
286
279
  height: 12px;
@@ -450,6 +443,7 @@ export default class Eplayer extends HTMLElement {
450
443
  <i class="epicon ep-speed">
451
444
  <b class="speed">1x</b>
452
445
  </i>
446
+ ${document.pictureInPictureEnabled && `<i class="epicon ep-pip"></i>`}
453
447
  <i class="epicon ep-full"></i>
454
448
  </div>
455
449
  </div>
@@ -489,6 +483,7 @@ export default class Eplayer extends HTMLElement {
489
483
  '.ep-full',
490
484
  '.panel',
491
485
  '.speed',
486
+ '.pip',
492
487
  ]
493
488
 
494
489
  for (const key of doms) {
@@ -518,6 +513,14 @@ export default class Eplayer extends HTMLElement {
518
513
  }
519
514
  }
520
515
 
516
+ pip(e) {
517
+ if (!document.pictureInPictureElement) {
518
+ this.video.requestPictureInPicture()
519
+ } else {
520
+ document.exitPictureInPicture()
521
+ }
522
+ }
523
+
521
524
  mount() {
522
525
  this.video = this.$('.video')
523
526
  this.video.volume = 0.5
@@ -535,6 +538,7 @@ export default class Eplayer extends HTMLElement {
535
538
  '.speed': this.speed,
536
539
  '.bg': this.progress,
537
540
  '.buffer': this.progress,
541
+ '.ep-pip': this.pip,
538
542
  })
539
543
  this.delegate('mousedown', {
540
544
  '.cycle': this.down,
@@ -554,7 +558,7 @@ export default class Eplayer extends HTMLElement {
554
558
  setVolume(index + 1, this.$('.line'))
555
559
  }
556
560
  })
557
- document.oncontextmenu = () => false
561
+ this.$('.eplayer').oncontextmenu = () => false
558
562
  }
559
563
  }
560
564
 
@@ -589,7 +593,7 @@ function isFullScreen() {
589
593
 
590
594
  ;(function () {
591
595
  let link = document.createElement('link')
592
- link.setAttribute('href', 'https://at.alicdn.com/t/font_836948_uhdb83b0e3m.css')
596
+ link.setAttribute('href', 'https://at.alicdn.com/t/font_836948_g9fk6jqpl8l.css')
593
597
  link.setAttribute('rel', 'stylesheet')
594
598
  document.head.appendChild(link)
595
- })()
599
+ })()