eplayer 1.5.4 → 1.5.5

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
@@ -4,21 +4,22 @@ class Eplayer extends HTMLElement {
4
4
  this.doms = {}
5
5
  this.src = this.getAttribute('src')
6
6
  this.type = this.getAttribute('type')
7
- this.beatMap = this.getAttribute('beatMap')
7
+ this.beatmap = this.getAttribute('beatmap')
8
8
 
9
9
  this.init()
10
10
  this.stream()
11
11
  }
12
12
 
13
13
  static get observedAttributes() {
14
- return ['src', 'type', 'beatMap']
14
+ return ['src', 'type', 'beatmap']
15
15
  }
16
16
 
17
17
  attributeChangedCallback(name, _, newVal) {
18
18
  if (name === 'src') this.src = this.$('.video').src = newVal
19
19
  if (name === 'type') this.type = newVal
20
- if (name === 'beatMap') this.beatMap = newVal
20
+ if (name === 'beatmap') this.beatmap = newVal
21
21
  this.stream()
22
+ this.startMug()
22
23
  this.video.load()
23
24
  }
24
25
 
@@ -26,14 +27,24 @@ class Eplayer extends HTMLElement {
26
27
  return this.doms[key]
27
28
  }
28
29
 
29
-
30
-
31
30
  waiting() {
32
31
  this.$('.mark').removeEventListener('click', this.mark.bind(this))
33
32
  this.$('.mark').classList.remove('playing')
34
33
  this.$('.mark').classList.add('loading')
35
34
  }
36
35
 
36
+ startMug() {
37
+ this.$('.mug').style.display = 'block'
38
+ this.$('.ep-video').style.display = 'none'
39
+ this.$('.controls').style.display = 'none'
40
+ if (!this.beatmap) return
41
+ const beats = this.beatmap.split('|').map(item => {
42
+ const [fps, button] = item.split(':')
43
+ return { fps, button }
44
+ })
45
+ new Mug(beats, this.$('.mug'), this.video)
46
+ }
47
+
37
48
  stream() {
38
49
  switch (this.type) {
39
50
  case 'hls':
@@ -47,24 +58,11 @@ class Eplayer extends HTMLElement {
47
58
  }
48
59
 
49
60
  mark() {
50
- if (this.beatMap) return
61
+ if (this.beatmap) return
51
62
  clearTimeout(this.timer)
52
63
  this.timer = setTimeout(() => this.play(), 200)
53
64
  }
54
65
 
55
- connectedCallback() {
56
- console.log('emmm')
57
- const beats = this.beatMap.split('|').map(item => {
58
- const [fps, button] = item.split(':')
59
- return {
60
- fps, button
61
- }
62
- })
63
-
64
-
65
- new Mug(beats,this.$('.mug'),this.video)
66
- }
67
-
68
66
  canplay() {
69
67
  this.$('.mark').classList.remove('loading')
70
68
  this.$('.mark').classList.add('playing')
@@ -73,7 +71,7 @@ class Eplayer extends HTMLElement {
73
71
  }
74
72
 
75
73
  play() {
76
- if (this.beatMap) return
74
+ if (this.beatmap) return
77
75
  if (this.video.paused) {
78
76
  this.video.play()
79
77
  this.$('.ep-video').style.display = 'none'
@@ -250,7 +248,7 @@ class Eplayer extends HTMLElement {
250
248
  overflow: hidden;
251
249
  }
252
250
  .controls{
253
- display:${this.beatMap ? 'none' : 'block'};
251
+ display:${this.beatmap ? 'none' : 'block'};
254
252
  position:absolute;
255
253
  left:0;
256
254
  right:0;
@@ -396,7 +394,7 @@ class Eplayer extends HTMLElement {
396
394
  }
397
395
  .ep-video {
398
396
  position: absolute;
399
- display:${this.beatMap ? 'none' : 'block'};
397
+ display:${this.beatmap ? 'none' : 'block'};
400
398
  bottom: 25px;
401
399
  right: 20px;
402
400
  font-size:40px;
@@ -445,6 +443,7 @@ class Eplayer extends HTMLElement {
445
443
  left: 50%;
446
444
  top: 50%;
447
445
  opacity: 0.95;
446
+ display: ${this.beatmap ? 'block' : 'none'}
448
447
  }
449
448
  .wrap{
450
449
  position: relative;
package/docs/index.html CHANGED
@@ -100,10 +100,14 @@
100
100
  }
101
101
  }
102
102
  </style>
103
+ <script>
104
+ setTimeout(() => {
105
+ document.querySelector('e-player').setAttribute('beatmap', '1:2|2:1|3:3|4:4|6:2|6:1|7:3|8:4|8:2|9:1|11:3|12:4|12:2|13:1|14:3|15:4|16:2|16:1|17:3|19:4|19:2|20:1|21:3|22:4')
106
+ }, 1000)
107
+ </script>
103
108
  <div class="wrapper">
104
109
 
105
- <e-player id="ep" src="https://mp4.ziyuan.wang/view.php/67c796ed2dad70c429bda73a647704f0.mp4"
106
- beatMap="1:2|2:1|3:3|4:4|6:2|6:1|7:3|8:4|8:2|9:1|11:3|12:4|12:2|13:1|14:3|15:4|16:2|16:1|17:3|19:4|19:2|20:1|21:3|22:4">
110
+ <e-player id="ep" src="https://mp4.ziyuan.wang/view.php/67c796ed2dad70c429bda73a647704f0.mp4">
107
111
  </e-player>
108
112
 
109
113
  <a href="https://github.com/132yse/eplayer">github</a>
package/docs/mug.js CHANGED
@@ -1,3 +1,5 @@
1
+ const assetUrl = 'https://registry.npmmirror.com/eplayer/1.5.4/files/docs/res'
2
+
1
3
  class Mug {
2
4
  constructor(beatMap, container, video) {
3
5
  this.container = container
@@ -79,7 +81,7 @@ class Mug {
79
81
  let gameCeng = new PIXI.Container()
80
82
  this.app.stage.addChild(gameCeng)
81
83
  //游戏背景
82
- let bg = new PIXI.Sprite.fromImage("res/beijing.png")
84
+ let bg = new PIXI.Sprite.fromImage(`${assetUrl}/beijing.png`)
83
85
  gameCeng.addChild(bg)
84
86
  //ui图层
85
87
  let uiCeng = new PIXI.Container()
@@ -103,7 +105,7 @@ class Mug {
103
105
  gameObjectCeng.addChild(scoreCeng)
104
106
 
105
107
  //点击位置
106
- let touming = new PIXI.Sprite.fromImage("res/touming.png")
108
+ let touming = new PIXI.Sprite.fromImage(`${assetUrl}/touming.png`)
107
109
  lineCeng.addChild(touming)
108
110
  touming.y = 600
109
111
  touming.x = 250
@@ -143,7 +145,7 @@ class Mug {
143
145
  scoreTxt.x = 130
144
146
  scoreTxt.y = 30
145
147
 
146
- let startBtn = new PIXI.Sprite.fromImage("res/kaishianniu.png")
148
+ let startBtn = new PIXI.Sprite.fromImage(`${assetUrl}/kaishianniu.png`)
147
149
  uiCeng.addChild(startBtn)
148
150
  startBtn.interactive = true
149
151
  startBtn.on("pointerdown", () => {
@@ -159,7 +161,7 @@ class Mug {
159
161
 
160
162
  over() {
161
163
  this.video.pause()
162
- let gameoverPanel = new PIXI.Sprite.fromImage("res/beiban.png")
164
+ let gameoverPanel = new PIXI.Sprite.fromImage(`${assetUrl}/beiban.png`)
163
165
  this.uiCeng.addChild(gameoverPanel)
164
166
  gameoverPanel.x = 20
165
167
  gameoverPanel.y = 100
@@ -174,7 +176,7 @@ class Mug {
174
176
  scoreTxt.x = 210
175
177
  scoreTxt.y = 110
176
178
 
177
- let restartBtn = new PIXI.Sprite.fromImage("res/fanhuianniu.png")
179
+ let restartBtn = new PIXI.Sprite.fromImage(`${assetUrl}/fanhuianniu.png`)
178
180
  gameoverPanel.addChild(restartBtn)
179
181
  restartBtn.x = 185
180
182
  restartBtn.y = 330
@@ -201,7 +203,7 @@ function getWorldPosition(displayObject) {
201
203
  class Button {
202
204
  constructor(imgNumber, gameObjectCeng, uiCeng, lineCeng, animalCeng, buttonX, that) {
203
205
  this.gameObjectCeng = gameObjectCeng
204
- this.bjt = new PIXI.Sprite.fromImage(`res/bjt${imgNumber}.png`)
206
+ this.bjt = new PIXI.Sprite.fromImage(`${assetUrl}/bjt${imgNumber}.png`)
205
207
  gameObjectCeng.addChild(this.bjt)
206
208
  this.bjt.anchor.set(0.5, 1)
207
209
  this.bjt.x = buttonX
@@ -209,14 +211,14 @@ class Button {
209
211
  this.bjt.visible = false
210
212
  this.animalCeng = animalCeng
211
213
 
212
- this.button = new PIXI.Sprite.fromImage(`res/anniu${imgNumber}.png`)
214
+ this.button = new PIXI.Sprite.fromImage(`${assetUrl}/anniu${imgNumber}.png`)
213
215
  uiCeng.addChild(this.button)
214
216
  this.button.anchor.set(0.5, 0.5)
215
217
  this.button.y = 754
216
218
  this.button.x = this.bjt.x
217
219
  this.type = imgNumber
218
220
 
219
- this.kong = new PIXI.Sprite.fromImage("res/kong.png")
221
+ this.kong = new PIXI.Sprite.fromImage(`${assetUrl}/kong.png`)
220
222
  lineCeng.addChild(this.kong)
221
223
  this.kong.anchor.set(0.5, 0.5)
222
224
  this.kong.x = this.bjt.x
@@ -310,7 +312,7 @@ class Button {
310
312
  }
311
313
 
312
314
  scoreAction(name) {
313
- let score = new PIXI.Sprite.fromImage("res/" + name + ".png")
315
+ let score = new PIXI.Sprite.fromImage(`${assetUrl}/` + name + ".png")
314
316
  this.gameObjectCeng.addChild(score)
315
317
  score.y = 540
316
318
  score.x = this.bjt.x
@@ -344,7 +346,7 @@ class Animal {
344
346
  3: "hong",
345
347
  4: "huang"
346
348
  }
347
- this.animal = new PIXI.Sprite.fromImage(`res/${typeMap[type]}${number}.png`)
349
+ this.animal = new PIXI.Sprite.fromImage(`${assetUrl}/${typeMap[type]}${number}.png`)
348
350
  this.animal.anchor.set(0.5, 0.5)
349
351
  this.animal.x = animalX
350
352
  this.animal.y = 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eplayer",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "description": "A web-components html5 video player facing future",
5
5
  "main": "./docs/eplayer.js",
6
6
  "module": "./docs/eplayer.js",