mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-17 01:56:16 -08:00
添加切换视频源
This commit is contained in:
1 parent
3e87417f82
commit
5fcff320cf
7 files changed
+98
-42
No files matched your search
+4
-2
@@ -16,7 +16,8 @@ let i18nMap = {
|
||||
'Play speed': '播放速度',
|
||||
'Aspect ratio': '画面比例',
|
||||
'Default': '默认',
|
||||
'Normal': '正常'
|
||||
'Normal': '正常',
|
||||
'Switch': '切换'
|
||||
},
|
||||
'zh-tw': {
|
||||
'About author': '關於作者',
|
||||
@@ -35,7 +36,8 @@ let i18nMap = {
|
||||
'Play speed': '播放速度',
|
||||
'Aspect ratio': '畫面比例',
|
||||
'Default': '默認',
|
||||
'Normal': '正常'
|
||||
'Normal': '正常',
|
||||
'Switch': '切換'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+13
-4
@@ -7,10 +7,15 @@ export default class Info {
|
||||
}
|
||||
|
||||
init() {
|
||||
const { refs: { $infoClose }, events: { proxy } } = this.art;
|
||||
const { refs: { $infoClose, $infoPanel }, events: { proxy } } = this.art;
|
||||
proxy($infoClose, 'click', () => {
|
||||
this.hide();
|
||||
});
|
||||
this.art.on('switch', () => {
|
||||
if ($infoPanel.innerHTML) {
|
||||
this.getHeader();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
@@ -45,14 +50,14 @@ export default class Info {
|
||||
infoHtml.push(`
|
||||
<div class="art-info-item">
|
||||
<div class="art-info-title">Video type:</div>
|
||||
<div class="art-info-content" data-head="Content-Type">loading...</div>
|
||||
<div class="art-info-content" data-head="Content-Type"></div>
|
||||
</div>
|
||||
`);
|
||||
|
||||
infoHtml.push(`
|
||||
<div class="art-info-item">
|
||||
<div class="art-info-title">Video size:</div>
|
||||
<div class="art-info-content" data-head="Content-length">loading...</div>
|
||||
<div class="art-info-content" data-head="Content-length"></div>
|
||||
</div>
|
||||
`);
|
||||
|
||||
@@ -90,8 +95,12 @@ export default class Info {
|
||||
}
|
||||
|
||||
getHeader() {
|
||||
const { option: { url }, refs: { $infoPanel } } = this.art;
|
||||
const { $infoPanel, $video } = this.art.refs;
|
||||
const url = $video.src;
|
||||
const types = Array.from($infoPanel.querySelectorAll('[data-head]'));
|
||||
types.forEach(item => {
|
||||
item.innerHTML = 'loading...';
|
||||
});
|
||||
fetch(url, {
|
||||
method: 'HEAD'
|
||||
}).then(data => {
|
||||
|
||||
@@ -165,6 +165,18 @@ export default class Player {
|
||||
return this.art.refs.$video.duration || 0;
|
||||
}
|
||||
|
||||
switch(url, name = 'Unknown') {
|
||||
const { refs: { $video }, i18n, notice, isPlaying } = this.art;
|
||||
const currentTime = this.currentTime();
|
||||
$video.src = url;
|
||||
this.seek(currentTime);
|
||||
if (isPlaying) {
|
||||
this.play();
|
||||
}
|
||||
notice.show(`${i18n.get('Switch')}: ${name}`);
|
||||
this.art.emit('switch', url);
|
||||
}
|
||||
|
||||
playbackRate(rate) {
|
||||
const { refs: { $video, $player }, i18n, notice } = this.art;
|
||||
const newRate = clamp(rate, 0.1, 10);
|
||||
|
||||
Reference in new issue
Block a user