eplayer 1.5.4 → 1.5.6
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 +26 -26
- package/docs/index.html +6 -2
- package/docs/mug.js +12 -10
- package/package.json +1 -1
package/docs/eplayer.js
CHANGED
|
@@ -4,21 +4,23 @@ class Eplayer extends HTMLElement {
|
|
|
4
4
|
this.doms = {}
|
|
5
5
|
this.src = this.getAttribute('src')
|
|
6
6
|
this.type = this.getAttribute('type')
|
|
7
|
-
this.
|
|
7
|
+
this.beatmap = this.getAttribute('beatmap')
|
|
8
|
+
this.high = this.getAttribute('high')
|
|
8
9
|
|
|
9
10
|
this.init()
|
|
10
11
|
this.stream()
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
|
|
13
14
|
static get observedAttributes() {
|
|
14
|
-
return ['src', 'type', '
|
|
15
|
+
return ['src', 'type', 'beatmap']
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
attributeChangedCallback(name, _, newVal) {
|
|
18
19
|
if (name === 'src') this.src = this.$('.video').src = newVal
|
|
19
20
|
if (name === 'type') this.type = newVal
|
|
20
|
-
if (name === '
|
|
21
|
+
if (name === 'beatmap') this.beatmap = newVal
|
|
21
22
|
this.stream()
|
|
23
|
+
this.startMug()
|
|
22
24
|
this.video.load()
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -26,14 +28,24 @@ class Eplayer extends HTMLElement {
|
|
|
26
28
|
return this.doms[key]
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
31
|
waiting() {
|
|
32
32
|
this.$('.mark').removeEventListener('click', this.mark.bind(this))
|
|
33
33
|
this.$('.mark').classList.remove('playing')
|
|
34
34
|
this.$('.mark').classList.add('loading')
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
startMug() {
|
|
38
|
+
this.$('.mug').style.display = 'block'
|
|
39
|
+
this.$('.ep-video').style.display = 'none'
|
|
40
|
+
this.$('.controls').style.display = 'none'
|
|
41
|
+
if (!this.beatmap) return
|
|
42
|
+
const beats = this.beatmap.split('|').map(item => {
|
|
43
|
+
const [fps, button] = item.split(':')
|
|
44
|
+
return { fps, button }
|
|
45
|
+
})
|
|
46
|
+
new Mug(beats, this.$('.mug'), this.video)
|
|
47
|
+
}
|
|
48
|
+
|
|
37
49
|
stream() {
|
|
38
50
|
switch (this.type) {
|
|
39
51
|
case 'hls':
|
|
@@ -47,24 +59,11 @@ class Eplayer extends HTMLElement {
|
|
|
47
59
|
}
|
|
48
60
|
|
|
49
61
|
mark() {
|
|
50
|
-
if (this.
|
|
62
|
+
if (this.beatmap) return
|
|
51
63
|
clearTimeout(this.timer)
|
|
52
64
|
this.timer = setTimeout(() => this.play(), 200)
|
|
53
65
|
}
|
|
54
66
|
|
|
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
67
|
canplay() {
|
|
69
68
|
this.$('.mark').classList.remove('loading')
|
|
70
69
|
this.$('.mark').classList.add('playing')
|
|
@@ -73,7 +72,7 @@ class Eplayer extends HTMLElement {
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
play() {
|
|
76
|
-
if (this.
|
|
75
|
+
if (this.beatmap) return
|
|
77
76
|
if (this.video.paused) {
|
|
78
77
|
this.video.play()
|
|
79
78
|
this.$('.ep-video').style.display = 'none'
|
|
@@ -250,7 +249,7 @@ class Eplayer extends HTMLElement {
|
|
|
250
249
|
overflow: hidden;
|
|
251
250
|
}
|
|
252
251
|
.controls{
|
|
253
|
-
display:${this.
|
|
252
|
+
display:${this.beatmap ? 'none' : 'block'};
|
|
254
253
|
position:absolute;
|
|
255
254
|
left:0;
|
|
256
255
|
right:0;
|
|
@@ -396,7 +395,7 @@ class Eplayer extends HTMLElement {
|
|
|
396
395
|
}
|
|
397
396
|
.ep-video {
|
|
398
397
|
position: absolute;
|
|
399
|
-
display:${this.
|
|
398
|
+
display:${this.beatmap ? 'none' : 'block'};
|
|
400
399
|
bottom: 25px;
|
|
401
400
|
right: 20px;
|
|
402
401
|
font-size:40px;
|
|
@@ -436,8 +435,8 @@ class Eplayer extends HTMLElement {
|
|
|
436
435
|
display:inline-block;
|
|
437
436
|
}
|
|
438
437
|
.mug {
|
|
439
|
-
height:
|
|
440
|
-
width:
|
|
438
|
+
height: ${this.high}px;
|
|
439
|
+
width: ${this.high/8*5}px;
|
|
441
440
|
position: absolute;
|
|
442
441
|
z-index: 999;
|
|
443
442
|
/* pointer-events: none; */
|
|
@@ -445,10 +444,11 @@ class Eplayer extends HTMLElement {
|
|
|
445
444
|
left: 50%;
|
|
446
445
|
top: 50%;
|
|
447
446
|
opacity: 0.95;
|
|
447
|
+
display: ${this.beatmap ? 'block' : 'none'}
|
|
448
448
|
}
|
|
449
449
|
.wrap{
|
|
450
450
|
position: relative;
|
|
451
|
-
height:
|
|
451
|
+
// height: ${this.high}px;
|
|
452
452
|
}
|
|
453
453
|
</style>
|
|
454
454
|
<div class="wrap">
|
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" high="450">
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|