Comparing version 0.2.10 to 0.3.0
@@ -11,5 +11,2 @@ 'use strict'; | ||
var OFFSETDOT = 18; | ||
copyright(); | ||
function getTimeStr(time) { | ||
@@ -30,3 +27,3 @@ var h = Math.floor(time / 3600); | ||
function copyright() { | ||
console.log('\n %c EPlayer 0.2.10 %c eplayer.js.org \n', 'color: #fff; background: linear-gradient(to right,#57a1fc ,#6beaf7); padding:5px;', 'color: #7192c3; background: #ecfaff; padding:5px 0;'); | ||
console.log('\n %c EPlayer 0.2.11 %c eplayer.js.org \n', 'color: #fff; background: linear-gradient(to right,#57a1fc ,#6beaf7); padding:5px;', 'color: #7192c3; background: #ecfaff; padding:5px 0;'); | ||
} | ||
@@ -39,2 +36,7 @@ | ||
function isMoblie() { | ||
return (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) | ||
); | ||
} | ||
var Init = function Init(el, data) { | ||
@@ -62,2 +64,5 @@ _classCallCheck(this, Init); | ||
var OFFSETDOT = 18; | ||
copyright(); | ||
var Eplayer = function () { | ||
@@ -97,7 +102,2 @@ function Eplayer(el, data) { | ||
if (isSafari()) { | ||
this.loading.style.display = 'none'; | ||
this.panel.style.display = 'block'; | ||
} | ||
this.tTime = 0; | ||
@@ -145,17 +145,35 @@ this.x = 0; | ||
}; | ||
this.dot.onmousemove = function (e) { | ||
this.dot.ontouchstart = function (e) { | ||
return _this.Dotonmousedown(e); | ||
}; | ||
this.el.onmousemove = function (e) { | ||
return _this.Dotonmousemove(e); | ||
}; | ||
this.dot.onmouseup = function (e) { | ||
this.el.ontouchmove = function (e) { | ||
return _this.Dotonmousemove(e); | ||
}; | ||
this.el.onmouseup = function (e) { | ||
return _this.Dotonmouseup(e); | ||
}; | ||
this.el.ontouchend = function (e) { | ||
return _this.Dotonmouseup(e); | ||
}; | ||
this.vdot.onmousedown = function (e) { | ||
return _this.Volumeonmousedown(e); | ||
}; | ||
this.vdot.ontouchstart = function (e) { | ||
return _this.Volumeonmousedown(e); | ||
}; | ||
this.vdot.onmousemove = function (e) { | ||
return _this.Volumeonmousemove(e); | ||
}; | ||
this.vdot.ontouchmove = function (e) { | ||
return _this.Volumeonmousemove(e); | ||
}; | ||
this.vdot.onmouseup = function (e) { | ||
return _this.Volumeonmouseup(e); | ||
}; | ||
this.vdot.ontouchend = function (e) { | ||
return _this.Volumeonmouseup(e); | ||
}; | ||
this.volumeBtn.onclick = function () { | ||
@@ -181,3 +199,3 @@ return _this.isVolume(); | ||
var tTimeStr = getTimeStr(this.tTime); | ||
this.totalTime.innerHTML = tTimeStr; | ||
if (tTimeStr) this.totalTime.innerHTML = tTimeStr; | ||
var vWidth = this.volumeProgress.clientWidth; | ||
@@ -258,5 +276,9 @@ this.video.volume = 0.7; | ||
value: function Dotonmousedown(e) { | ||
var event = e || window.event; | ||
this.x = event.clientX; | ||
this.l = this.l ? this.l : event.offsetX; | ||
if (e.changedTouches) { | ||
this.x = e.changedTouches[0].clientX; | ||
} else { | ||
this.x = e.clientX; | ||
} | ||
this.l = this.l ? this.l : 0; | ||
this.isDown = true; | ||
@@ -268,5 +290,8 @@ } | ||
if (this.isDown) { | ||
var event = e || window.event; | ||
if (e.changedTouches) { | ||
this.nx = e.changedTouches[0].clientX; | ||
} else { | ||
this.nx = e.clientX; | ||
} | ||
this.nx = event.clientX; | ||
this.nl = this.nx - (this.x - this.l); | ||
@@ -284,3 +309,2 @@ if (this.nl <= 0) this.nl = 0; | ||
value: function Dotonmouseup(e) { | ||
var event = e || window.event; | ||
this.video.currentTime = this.nl / this.progress.offsetWidth * this.video.duration; | ||
@@ -292,6 +316,10 @@ this.isDown = false; | ||
value: function Volumeonmousedown(e) { | ||
var event = e || window.event; | ||
this.vx = event.clientX; | ||
this.vl = this.vl !== 0 ? this.vl : event.offsetX; | ||
if (e.changedTouches) { | ||
this.vx = e.changedTouches[0].clientX; | ||
} else { | ||
this.vx = e.clientX; | ||
} | ||
this.vl = this.vl !== 0 ? this.vl : 0; | ||
this.isDown = true; | ||
e.stopPropagation(); | ||
} | ||
@@ -302,5 +330,8 @@ }, { | ||
if (this.isDown) { | ||
var event = e || window.event; | ||
this.vnx = event.clientX; | ||
if (e.changedTouches) { | ||
this.vnx = e.changedTouches[0].clientX; | ||
} else { | ||
this.vnx = e.clientX; | ||
} | ||
console.log(this.vx, this.vl, this.vnx); | ||
this.vnl = this.vnx - (this.vx - this.vl); | ||
@@ -314,2 +345,3 @@ if (this.vnl <= 0) this.vnl = 0; | ||
} | ||
e.stopPropagation(); | ||
} | ||
@@ -319,5 +351,5 @@ }, { | ||
value: function Volumeonmouseup(e) { | ||
var event = e || window.event; | ||
this.isDown = false; | ||
this.video.volume = this.vnl / this.volumeProgress.clientWidth; | ||
e.stopPropagation(); | ||
} | ||
@@ -324,0 +356,0 @@ }, { |
{ | ||
"name": "eplayer", | ||
"version": "0.2.10", | ||
"version": "0.3.0", | ||
"description": "A simple html5 video player", | ||
@@ -5,0 +5,0 @@ "main": "./lib/eplayer.js", |
import { Init } from './init' | ||
import { Hls } from './hls' | ||
import { getTimeStr, isFullScreen, copyright, isSafari } from './util' | ||
import { getTimeStr, isFullScreen, copyright, isMoblie } from './util' | ||
@@ -40,7 +40,2 @@ const OFFSETDOT = 18 | ||
if (isSafari()) { | ||
this.loading.style.display = 'none' | ||
this.panel.style.display = 'block' | ||
} | ||
this.tTime = 0 | ||
@@ -70,7 +65,13 @@ this.x = 0 | ||
this.dot.onmousedown = e => this.Dotonmousedown(e) | ||
this.dot.onmousemove = e => this.Dotonmousemove(e) | ||
this.dot.onmouseup = e => this.Dotonmouseup(e) | ||
this.dot.ontouchstart = e => this.Dotonmousedown(e) | ||
this.el.onmousemove = e => this.Dotonmousemove(e) | ||
this.el.ontouchmove = e => this.Dotonmousemove(e) | ||
this.el.onmouseup = e => this.Dotonmouseup(e) | ||
this.el.ontouchend = e => this.Dotonmouseup(e) | ||
this.vdot.onmousedown = e => this.Volumeonmousedown(e) | ||
this.vdot.ontouchstart = e => this.Volumeonmousedown(e) | ||
this.vdot.onmousemove = e => this.Volumeonmousemove(e) | ||
this.vdot.ontouchmove = e => this.Volumeonmousemove(e) | ||
this.vdot.onmouseup = e => this.Volumeonmouseup(e) | ||
this.vdot.ontouchend = e => this.Volumeonmouseup(e) | ||
this.volumeBtn.onclick = () => this.isVolume() | ||
@@ -89,3 +90,3 @@ window.onresize = e => this.windowResize(e) | ||
let tTimeStr = getTimeStr(this.tTime) | ||
this.totalTime.innerHTML = tTimeStr | ||
if (tTimeStr) this.totalTime.innerHTML = tTimeStr | ||
let vWidth = this.volumeProgress.clientWidth | ||
@@ -165,5 +166,9 @@ this.video.volume = 0.7 | ||
Dotonmousedown(e) { | ||
let event = e || window.event | ||
this.x = event.clientX | ||
this.l = this.l ? this.l : event.offsetX | ||
if (e.changedTouches) { | ||
this.x = e.changedTouches[0].clientX | ||
} else { | ||
this.x = e.clientX | ||
} | ||
this.l = this.l ? this.l : 0 | ||
this.isDown = true | ||
@@ -174,5 +179,8 @@ } | ||
if (this.isDown) { | ||
let event = e || window.event | ||
if (e.changedTouches) { | ||
this.nx = e.changedTouches[0].clientX | ||
} else { | ||
this.nx = e.clientX | ||
} | ||
this.nx = event.clientX | ||
this.nl = this.nx - (this.x - this.l) | ||
@@ -190,3 +198,2 @@ if (this.nl <= 0) this.nl = 0 | ||
Dotonmouseup(e) { | ||
let event = e || window.event | ||
this.video.currentTime = | ||
@@ -198,6 +205,10 @@ (this.nl / this.progress.offsetWidth) * this.video.duration | ||
Volumeonmousedown(e) { | ||
let event = e || window.event | ||
this.vx = event.clientX | ||
this.vl = this.vl !== 0 ? this.vl : event.offsetX | ||
if (e.changedTouches) { | ||
this.vx = e.changedTouches[0].clientX | ||
} else { | ||
this.vx = e.clientX | ||
} | ||
this.vl = this.vl !== 0 ? this.vl : 0 | ||
this.isDown = true | ||
e.stopPropagation() | ||
} | ||
@@ -207,5 +218,8 @@ | ||
if (this.isDown) { | ||
let event = e || window.event | ||
this.vnx = event.clientX | ||
if (e.changedTouches) { | ||
this.vnx = e.changedTouches[0].clientX | ||
} else { | ||
this.vnx = e.clientX | ||
} | ||
console.log(this.vx,this.vl,this.vnx) | ||
this.vnl = this.vnx - (this.vx - this.vl) | ||
@@ -220,8 +234,9 @@ if (this.vnl <= 0) this.vnl = 0 | ||
} | ||
e.stopPropagation() | ||
} | ||
Volumeonmouseup(e) { | ||
let event = e || window.event | ||
this.isDown = false | ||
this.video.volume = this.vnl / this.volumeProgress.clientWidth | ||
e.stopPropagation() | ||
} | ||
@@ -228,0 +243,0 @@ |
@@ -21,3 +21,3 @@ export function getTimeStr(time) { | ||
console.log( | ||
'\n %c EPlayer 0.2.8 %c eplayer.js.org \n', | ||
'\n %c EPlayer 0.2.11 %c eplayer.js.org \n', | ||
'color: #fff; background: linear-gradient(to right,#57a1fc ,#6beaf7); padding:5px;', | ||
@@ -30,2 +30,7 @@ 'color: #7192c3; background: #ecfaff; padding:5px 0;' | ||
return /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) | ||
} | ||
export function isMoblie(){ | ||
return /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) | ||
} |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1403355
19
2701
4
13