mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-20 12:11:20 -08:00
更新url重连次数的刷新
This commit is contained in:
1 parent
a4876e6c73
commit
a84521cc98
6 files changed
+46
-30
No files matched your search
+13
-9
@@ -3,27 +3,31 @@ import { append } from '../utils';
|
||||
export default class Quality {
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
this.playIndex = -1;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
const { option, events: { proxy, hover }, player } = this.art;
|
||||
const { $control } = this.option;
|
||||
const { option, events: { proxy, hover }, player } = art;
|
||||
const defaultQuality = option.quality.find(item => item.default) || option.quality[0];
|
||||
const $qualityName = append(this.option.$control, `<div class="art-quality-name">${defaultQuality.name}</div>`);
|
||||
this.playIndex = option.quality.indexOf(defaultQuality);
|
||||
const $qualityName = append($control, `<div class="art-quality-name">${defaultQuality.name}</div>`);
|
||||
const qualityList = option.quality.map((item, index) => `<div class="art-quality-item" data-index="${index}">${item.name}</div>`).join('');
|
||||
const $qualitys = append(this.option.$control, `<div class="art-qualitys">${qualityList}</div>`);
|
||||
const $qualitys = append($control, `<div class="art-qualitys">${qualityList}</div>`);
|
||||
|
||||
hover(this.option.$control, () => {
|
||||
this.option.$control.classList.add('hover');
|
||||
hover($control, () => {
|
||||
$control.classList.add('hover');
|
||||
}, () => {
|
||||
this.option.$control.classList.remove('hover');
|
||||
$control.classList.remove('hover');
|
||||
});
|
||||
|
||||
proxy($qualitys, 'click', event => {
|
||||
const { url, name } = option.quality[event.target.dataset.index];
|
||||
if (url && name) {
|
||||
const index = Number(event.target.dataset.index);
|
||||
const { url, name } = option.quality[index];
|
||||
if (url && name && this.playIndex !== index) {
|
||||
player.switch(url, name);
|
||||
$qualityName.innerHTML = name;
|
||||
this.playIndex = index;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export default class Screenshot {
|
||||
const elink = document.createElement('a');
|
||||
setStyle(elink, 'display', 'none');
|
||||
elink.href = dataUri;
|
||||
elink.download = `${secondToTime($video.currentTime)}.png`;
|
||||
elink.download = `ArtPlayer_${secondToTime($video.currentTime)}.png`;
|
||||
document.body.appendChild(elink);
|
||||
elink.click();
|
||||
document.body.removeChild(elink);
|
||||
|
||||
@@ -77,6 +77,7 @@ class Artplayer extends Emitter {
|
||||
controls: [],
|
||||
highlight: [],
|
||||
moreVideoAttr: {
|
||||
'crossOrigin': 'anonymous',
|
||||
'controls': false,
|
||||
'preload': 'auto',
|
||||
'webkit-playsinline': true,
|
||||
|
||||
+4
-1
@@ -121,6 +121,7 @@ export default class Player {
|
||||
if (promise !== undefined) {
|
||||
promise.then().catch(err => {
|
||||
notice.show(err, true, 3000);
|
||||
console.warn(err);
|
||||
});
|
||||
}
|
||||
notice.show(i18n.get('Play'));
|
||||
@@ -175,9 +176,11 @@ export default class Player {
|
||||
}
|
||||
|
||||
switch(url, name = 'Unknown') {
|
||||
const { refs: { $video }, i18n, notice, isPlaying } = this.art;
|
||||
const { refs: { $video }, i18n, notice, isPlaying, option } = this.art;
|
||||
const currentTime = this.currentTime();
|
||||
$video.src = url;
|
||||
option.url = url;
|
||||
this.reconnectTime = 0;
|
||||
this.seek(currentTime);
|
||||
if (isPlaying) {
|
||||
this.play();
|
||||
|
||||
Reference in new issue
Block a user