Comparing version 1.2.1 to 1.2.2
@@ -384,3 +384,3 @@ class Eplayer extends HTMLElement { | ||
this.video.volume = 0.5 | ||
setVolume(this.video.volume * 10, this.$(".line")) | ||
setVolume(this.video.volume * 10 + 1, this.$('.line')) | ||
this.$(".is-volume").onclick = () => this.volume() | ||
@@ -387,0 +387,0 @@ this.$(".line").forEach((item, index) => { |
{ | ||
"name": "eplayer", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "A web-components html5 video player facing future", | ||
@@ -5,0 +5,0 @@ "main": "./dist/eplayer.js", |
class Eplayer extends HTMLElement { | ||
constructor() { | ||
super() | ||
this.src = this.getAttribute("src") | ||
this.type = this.getAttribute("type") | ||
this.src = this.getAttribute('src') | ||
this.type = this.getAttribute('type') | ||
this.init() | ||
@@ -11,9 +11,9 @@ this.stream() | ||
static get observedAttributes() { | ||
return ["src", "type"] | ||
return ['src', 'type'] | ||
} | ||
attributeChangedCallback(name, _, newVal) { | ||
if (name === "src") this.src = this.$(".source").src = newVal | ||
if (name === "type") { | ||
this.$(".source").type = `video/${newVal}` | ||
if (name === 'src') this.src = this.$('.source').src = newVal | ||
if (name === 'type') { | ||
this.$('.source').type = `video/${newVal}` | ||
this.type = newVal | ||
@@ -26,4 +26,4 @@ } | ||
waiting() { | ||
this.$(".mark").classList.remove("playing") | ||
this.$(".mark").classList.add("loading") | ||
this.$('.mark').classList.remove('playing') | ||
this.$('.mark').classList.add('loading') | ||
} | ||
@@ -33,3 +33,3 @@ | ||
switch (this.type) { | ||
case "hls": | ||
case 'hls': | ||
if (Hls.isSupported()) { | ||
@@ -41,5 +41,5 @@ let hls = new Hls() | ||
break | ||
case "flv": | ||
case 'flv': | ||
if (flvjs.isSupported()) { | ||
let flvPlayer = flvjs.createPlayer({ type: "flv", url: this.src }) | ||
let flvPlayer = flvjs.createPlayer({ type: 'flv', url: this.src }) | ||
flvPlayer.attachMediaElement(this.video) | ||
@@ -53,5 +53,5 @@ flvPlayer.load() | ||
canplay() { | ||
this.$(".mark").classList.remove("loading") | ||
this.$(".mark").classList.add("playing") | ||
this.$(".playing").onclick = () => { | ||
this.$('.mark').classList.remove('loading') | ||
this.$('.mark').classList.add('playing') | ||
this.$('.playing').onclick = () => { | ||
clearTimeout(this.timer) | ||
@@ -62,3 +62,3 @@ this.timer = setTimeout(() => { | ||
} | ||
this.$(".total").innerHTML = getTimeStr(this.video.duration) | ||
this.$('.total').innerHTML = getTimeStr(this.video.duration) | ||
} | ||
@@ -69,8 +69,8 @@ | ||
this.video.play() | ||
this.$(".ep-video").style.display = "none" | ||
this.$(".is-play").classList.replace("ep-play", "ep-pause") | ||
this.$('.ep-video').style.display = 'none' | ||
this.$('.is-play').classList.replace('ep-play', 'ep-pause') | ||
} else { | ||
this.video.pause() | ||
this.$(".ep-video").style.display = "block" | ||
this.$(".is-play").classList.replace("ep-pause", "ep-play") | ||
this.$('.ep-video').style.display = 'block' | ||
this.$('.is-play').classList.replace('ep-pause', 'ep-play') | ||
} | ||
@@ -83,8 +83,8 @@ return false | ||
this.video.muted = false | ||
setVolume(this.video.volume * 10, this.$(".line")) | ||
this.$(".is-volume").classList.replace("ep-volume-off", "ep-volume") | ||
setVolume(this.video.volume * 10 + 1, this.$('.line')) | ||
this.$('.is-volume').classList.replace('ep-volume-off', 'ep-volume') | ||
} else { | ||
this.video.muted = true | ||
setVolume(0, this.$(".line")) | ||
this.$(".is-volume").classList.replace("ep-volume", "ep-volume-off") | ||
setVolume(0, this.$('.line')) | ||
this.$('.is-volume').classList.replace('ep-volume', 'ep-volume-off') | ||
} | ||
@@ -98,15 +98,15 @@ return false | ||
let bufferEnd = this.video.buffered.end(this.video.buffered.length - 1) | ||
this.$(".buffer").style.width = | ||
(bufferEnd / this.video.duration) * this.$(".progress").clientWidth + | ||
"px" | ||
this.$('.buffer').style.width = | ||
(bufferEnd / this.video.duration) * this.$('.progress').clientWidth + | ||
'px' | ||
} | ||
let offset = | ||
(this.video.currentTime / this.video.duration) * this.$(".bg").clientWidth | ||
this.$(".now").innerHTML = cTime | ||
this.$(".current").style.width = offset + "px" | ||
this.$(".dot").style.left = offset + "px" | ||
(this.video.currentTime / this.video.duration) * this.$('.bg').clientWidth | ||
this.$('.now').innerHTML = cTime | ||
this.$('.current').style.width = offset + 'px' | ||
this.$('.dot').style.left = offset + 'px' | ||
} | ||
progress(e) { | ||
let offset = e.offsetX / this.$(".progress").offsetWidth | ||
let offset = e.offsetX / this.$('.progress').offsetWidth | ||
this.video.currentTime = this.video.duration * offset | ||
@@ -117,3 +117,3 @@ return false | ||
down(e) { | ||
this.disX = e.clientX - this.$(".dot").offsetLeft | ||
this.disX = e.clientX - this.$('.dot').offsetLeft | ||
document.onmousemove = e => this.move(e) | ||
@@ -129,12 +129,15 @@ document.onmouseup = () => { | ||
if (offset < 0) offset = 0 | ||
if (offset > this.$(".progress").clientWidth) | ||
offset = this.$(".progress").clientWidth | ||
this.$(".current").style.width = offset + "px" | ||
this.$(".dot").style.left = offset + "px" | ||
if (offset > this.$('.progress').clientWidth) | ||
offset = this.$('.progress').clientWidth | ||
this.$('.current').style.width = offset + 'px' | ||
this.$('.dot').style.left = offset + 'px' | ||
this.video.currentTime = | ||
(offset / this.$(".progress").clientWidth) * this.video.duration | ||
(offset / this.$('.progress').clientWidth) * this.video.duration | ||
document.onmousemove = null | ||
setTimeout(document.onmousemove = e => { | ||
setTimeout( | ||
(document.onmousemove = e => { | ||
if (e) this.move(e) | ||
},30) | ||
}), | ||
30 | ||
) | ||
} | ||
@@ -144,9 +147,9 @@ | ||
clearTimeout(this.timer) | ||
this.$(".controls").style.bottom = 0 | ||
this.$(".dot").style.bottom = 39 + "px" | ||
this.$(".ep-video").style.bottom = 70 + "px" | ||
this.$('.controls').style.bottom = 0 | ||
this.$('.dot').style.bottom = 39 + 'px' | ||
this.$('.ep-video').style.bottom = 70 + 'px' | ||
this.timer = setTimeout(() => { | ||
this.$(".controls").style.bottom = -42 + "px" | ||
this.$(".dot").style.bottom = -42 + "px" | ||
this.$(".ep-video").style.bottom = 25 + "px" | ||
this.$('.controls').style.bottom = -42 + 'px' | ||
this.$('.dot').style.bottom = -42 + 'px' | ||
this.$('.ep-video').style.bottom = 25 + 'px' | ||
}, 5000) | ||
@@ -156,3 +159,3 @@ } | ||
ended() { | ||
this.$(".is-play").classList.replace("ep-pause", "ep-play") | ||
this.$('.is-play').classList.replace('ep-pause', 'ep-play') | ||
} | ||
@@ -172,3 +175,3 @@ | ||
} else { | ||
let el = this.$(".eplayer") | ||
let el = this.$('.eplayer') | ||
let rfs = | ||
@@ -184,8 +187,8 @@ el.requestFullScreen || | ||
init() { | ||
let link = document.createElement("link") | ||
let link = document.createElement('link') | ||
link.setAttribute( | ||
"href", | ||
"https://at.alicdn.com/t/font_836948_6lbb2iu59.css" | ||
'href', | ||
'https://at.alicdn.com/t/font_836948_6lbb2iu59.css' | ||
) | ||
link.setAttribute("rel", "stylesheet") | ||
link.setAttribute('rel', 'stylesheet') | ||
document.head.appendChild(link) | ||
@@ -351,3 +354,3 @@ let html = ` | ||
<source src="${this.src}" type="video/${ | ||
this.type ? this.type : "mp4" | ||
this.type ? this.type : 'mp4' | ||
}" class="source"> | ||
@@ -389,6 +392,6 @@ </video> | ||
` | ||
let template = document.createElement("template") | ||
let template = document.createElement('template') | ||
template.innerHTML = html | ||
this.attachShadow({ | ||
mode: "open" | ||
mode: 'open' | ||
}).appendChild(template.content.cloneNode(true)) | ||
@@ -399,14 +402,14 @@ this.dom() | ||
dom() { | ||
this.video = this.$("video") | ||
this.video = this.$('video') | ||
this.video.volume = 0.5 | ||
setVolume(this.video.volume * 10, this.$(".line")) | ||
this.$(".is-volume").onclick = () => this.volume() | ||
this.$(".line").forEach((item, index) => { | ||
setVolume(this.video.volume * 10, this.$('.line')) | ||
this.$('.is-volume').onclick = () => this.volume() | ||
this.$('.line').forEach((item, index) => { | ||
item.onclick = () => { | ||
this.video.volume = index / 10 | ||
setVolume(index + 1, this.$(".line")) | ||
setVolume(index + 1, this.$('.line')) | ||
} | ||
}) | ||
this.$(".dot").onmousedown = e => this.down(e) | ||
this.$(".progress").onclick = e => this.progress(e) | ||
this.$('.dot').onmousedown = e => this.down(e) | ||
this.$('.progress').onclick = e => this.progress(e) | ||
this.video.onwaiting = () => this.waiting() | ||
@@ -416,7 +419,7 @@ this.video.oncanplay = () => this.canplay() | ||
this.$(".eplayer").onmousemove = () => this.alow() | ||
this.$(".ep-full").onclick = () => this.full() | ||
this.$(".ep-video").onclick = this.$(".is-play").onclick = () => this.play() | ||
this.$('.eplayer').onmousemove = () => this.alow() | ||
this.$('.ep-full').onclick = () => this.full() | ||
this.$('.ep-video').onclick = this.$('.is-play').onclick = () => this.play() | ||
this.video.onended = () => this.ended() | ||
this.$(".mark").ondblclick = () => { | ||
this.$('.mark').ondblclick = () => { | ||
clearTimeout(this.timer) | ||
@@ -439,6 +442,6 @@ this.full() | ||
let s = Math.floor(time % 60) | ||
h = h >= 10 ? h : "0" + h | ||
m = m >= 10 ? m : "0" + m | ||
s = s >= 10 ? s : "0" + s | ||
return h === "00" ? m + ":" + s : h + ":" + m + ":" + s | ||
h = h >= 10 ? h : '0' + h | ||
m = m >= 10 ? m : '0' + m | ||
s = s >= 10 ? s : '0' + s | ||
return h === '00' ? m + ':' + s : h + ':' + m + ':' + s | ||
} | ||
@@ -448,6 +451,6 @@ | ||
for (let j = index; j < node.length; j++) { | ||
node[j].classList.remove("active") | ||
node[j].classList.remove('active') | ||
} | ||
for (let i = 0; i < index; i++) { | ||
node[i].classList.add("active") | ||
node[i].classList.add('active') | ||
} | ||
@@ -454,0 +457,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54977
1479