229 lines
7.8 KiB
JavaScript
229 lines
7.8 KiB
JavaScript
// stats.js: JavaScript Performance Monitor
|
|
const stats = new Stats();
|
|
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
|
|
document.body.appendChild(stats.dom);
|
|
function animate () {
|
|
stats.begin();
|
|
// monitored code goes here
|
|
stats.end();
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
requestAnimationFrame(animate);
|
|
|
|
initPlayers();
|
|
|
|
function initPlayers () {
|
|
// dp1
|
|
window.dp1 = new DPlayer({
|
|
container: document.getElementById('dplayer1'),
|
|
preload: 'none',
|
|
screenshot: true,
|
|
video: {
|
|
url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.mp4',
|
|
pic: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.png',
|
|
thumbnails: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara_thumbnails.jpg'
|
|
},
|
|
subtitle: {
|
|
url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.vtt'
|
|
},
|
|
danmaku: {
|
|
id: '9E2E3368B56CDBB4',
|
|
api: 'https://dan.prprpr.me/'
|
|
}
|
|
});
|
|
|
|
// dp2
|
|
window.dp2 = new DPlayer({
|
|
container: document.getElementById('dplayer2'),
|
|
preload: 'none',
|
|
autoplay: false,
|
|
theme: '#FADFA3',
|
|
loop: true,
|
|
screenshot: true,
|
|
hotkey: true,
|
|
logo: 'https://moeplayer.b0.upaiyun.com/dplayer/DPlayer.png',
|
|
volume: 0.2,
|
|
mutex: true,
|
|
video: {
|
|
url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.mp4',
|
|
pic: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.png',
|
|
thumbnails: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara_thumbnails.jpg',
|
|
type: 'auto'
|
|
},
|
|
subtitle: {
|
|
url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.vtt',
|
|
type: 'webvtt',
|
|
fontSize: '25px',
|
|
bottom: '10%',
|
|
color: '#b7daff'
|
|
},
|
|
danmaku: {
|
|
id: '9E2E3368B56CDBB4',
|
|
api: 'https://dan.prprpr.me/',
|
|
token: 'tokendemo',
|
|
maximum: 3000,
|
|
user: 'DIYgod',
|
|
bottom: '15%',
|
|
unlimited: true
|
|
},
|
|
contextmenu: [
|
|
{
|
|
text: 'custom contextmenu',
|
|
link: 'https://github.com/MoePlayer/DPlayer'
|
|
}
|
|
]
|
|
});
|
|
|
|
const events = [
|
|
'abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'ended', 'error',
|
|
'loadeddata', 'loadedmetadata', 'loadstart', 'mozaudioavailable', 'pause', 'play',
|
|
'playing', 'ratechange', 'seeked', 'seeking', 'stalled',
|
|
'volumechange', 'waiting',
|
|
'screenshot',
|
|
'thumbnails_show', 'thumbnails_hide',
|
|
'danmaku_show', 'danmaku_hide', 'danmaku_clear',
|
|
'danmaku_loaded', 'danmaku_send', 'danmaku_opacity',
|
|
'contextmenu_show', 'contextmenu_hide',
|
|
'notice_show', 'notice_hide',
|
|
'quality_start', 'quality_end',
|
|
'destroy',
|
|
'resize',
|
|
'fullscreen', 'fullscreen_cancel', 'webfullscreen', 'webfullscreen_cancel',
|
|
'subtitle_show', 'subtitle_hide', 'subtitle_change'
|
|
];
|
|
const eventsEle = document.getElementById('events');
|
|
for (let i = 0; i < events.length; i++) {
|
|
dp2.on(events[i], (info) => {
|
|
eventsEle.innerHTML += '<p>Event: ' + events[i] + '</p>';
|
|
eventsEle.scrollTop = eventsEle.scrollHeight;
|
|
});
|
|
}
|
|
|
|
// dp3
|
|
// window.dp3 = new DPlayer({
|
|
// container: document.getElementById('dplayer3'),
|
|
// preload: 'none',
|
|
// video: {
|
|
// quality: [{
|
|
// name: 'HD',
|
|
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
|
|
// type: 'hls'
|
|
// }, {
|
|
// name: 'SD',
|
|
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.mp4',
|
|
// type: 'normal'
|
|
// }],
|
|
// defaultQuality: 0,
|
|
// pic: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.png'
|
|
// }
|
|
// });
|
|
|
|
// // dp4
|
|
// window.dp4 = new DPlayer({
|
|
// container: document.getElementById('dplayer4'),
|
|
// preload: 'none',
|
|
// video: {
|
|
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
|
|
// type: 'hls'
|
|
// }
|
|
// });
|
|
|
|
// // dp5
|
|
// window.dp5 = new DPlayer({
|
|
// container: document.getElementById('dplayer5'),
|
|
// preload: 'none',
|
|
// video: {
|
|
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.flv',
|
|
// type: 'flv'
|
|
// }
|
|
// });
|
|
|
|
// window.dp8 = new DPlayer({
|
|
// container: document.getElementById('dplayer8'),
|
|
// preload: 'none',
|
|
// video: {
|
|
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/dash/hikarunara.mpd',
|
|
// type: 'dash'
|
|
// }
|
|
// });
|
|
|
|
// window.dp9 = new DPlayer({
|
|
// container: document.getElementById('dplayer9'),
|
|
// video: {
|
|
// url: 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent',
|
|
// type: 'webtorrent'
|
|
// }
|
|
// });
|
|
|
|
// window.dp6 = new DPlayer({
|
|
// container: document.getElementById('dplayer6'),
|
|
// preload: 'none',
|
|
// live: true,
|
|
// danmaku: true,
|
|
// apiBackend: {
|
|
// read: function (endpoint, callback) {
|
|
// console.log('假装 WebSocket 连接成功');
|
|
// callback();
|
|
// },
|
|
// send: function (endpoint, danmakuData, callback) {
|
|
// console.log('假装通过 WebSocket 发送数据', danmakuData);
|
|
// callback();
|
|
// }
|
|
// },
|
|
// video: {
|
|
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
|
|
// type: 'hls'
|
|
// }
|
|
// });
|
|
|
|
// window.dp10 = new DPlayer({
|
|
// container: document.getElementById('dplayer10'),
|
|
// video: {
|
|
// url: 'https://qq.webrtc.win/tv/Pear-Demo-Yosemite_National_Park.mp4',
|
|
// type: 'pearplayer',
|
|
// customType: {
|
|
// 'pearplayer': function (video, player) {
|
|
// new PearPlayer(video, {
|
|
// src: video.src,
|
|
// autoplay: player.options.autoplay
|
|
// });
|
|
// }
|
|
// }
|
|
// }
|
|
// });
|
|
}
|
|
|
|
function clearPlayers () {
|
|
for (let i = 0; i < 6; i++) {
|
|
window['dp' + (i + 1)].pause();
|
|
document.getElementById('dplayer' + (i + 1)).innerHTML = '';
|
|
}
|
|
}
|
|
|
|
function switchDPlayer () {
|
|
if (dp2.option.danmaku.id !== '5rGf5Y2X55qu6Z2p') {
|
|
dp2.switchVideo({
|
|
url: 'https://moeplayer.b0.upaiyun.com/dplayer/flowerdance.mp4',
|
|
pic: 'https://moeplayer.b0.upaiyun.com/dplayer/flowerdance.jpg',
|
|
type: 'auto',
|
|
}, {
|
|
id: '5rGf5Y2X55qu6Z2p',
|
|
api: 'https://dan.prprpr.me/',
|
|
maximum: 3000,
|
|
user: 'DIYgod'
|
|
});
|
|
} else {
|
|
dp2.switchVideo({
|
|
url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.mp4',
|
|
pic: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.png',
|
|
thumbnails: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara_thumbnails.jpg',
|
|
type: 'auto'
|
|
}, {
|
|
id: '9E2E3368B56CDBB42',
|
|
api: 'https://dan.prprpr.me/',
|
|
maximum: 3000,
|
|
user: 'DIYgod'
|
|
});
|
|
}
|
|
} |