Partial upload-202301021631
This commit is contained in:
parent
8d5168fc2a
commit
f534f6fa26
@ -20,6 +20,7 @@ TODO:
|
||||
* [x] 更改一下循环逻辑,在结尾增加一定空格 **(勉强能用,需要修正)**
|
||||
* [ ] 随机播放逻辑代码
|
||||
* [ ] 循环播放逻辑代码测试和调整
|
||||
* [ ] 加入“我喜欢的音乐”(工程量略大)
|
||||
|
||||
---
|
||||
Changelog:
|
||||
|
||||
39
js/main.js
39
js/main.js
@ -89,6 +89,7 @@ class TitleStat{
|
||||
}
|
||||
}
|
||||
|
||||
// Player Controller
|
||||
class PlayerControl{
|
||||
constructor() {
|
||||
|
||||
@ -97,6 +98,13 @@ class PlayerControl{
|
||||
playerObject = document.getElementById('Player');
|
||||
ListenerStatus = false;
|
||||
|
||||
FuncObj = null;
|
||||
|
||||
// 神秘函数
|
||||
setFunction(){
|
||||
this.FuncObj = this.playStatCheck;
|
||||
}
|
||||
|
||||
// 创建事件监听器
|
||||
enableListener( func ) {
|
||||
this.playerObject.addEventListener('ended', func());
|
||||
@ -116,14 +124,35 @@ class PlayerControl{
|
||||
return this.ListenerStatus;
|
||||
}
|
||||
|
||||
// 启动检测
|
||||
startCheck(){
|
||||
if (this.ListenerStatus == true) {
|
||||
this.disableListener(this.FuncObj);
|
||||
}
|
||||
this.enableListener(this.FuncObj);
|
||||
}
|
||||
|
||||
// 停止检测
|
||||
stopCheck(){
|
||||
if (this.ListenerStatus == true) {
|
||||
this.disableListener(this.FuncObj);
|
||||
} else{
|
||||
console.error("失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/* 默认函数 */
|
||||
// 播放状态检测
|
||||
playStatCheck(){
|
||||
console.log(this);
|
||||
// debug
|
||||
console.warn("当前模式:" + CyclePlayMode);
|
||||
// 是否单曲?
|
||||
if ( CyclePlayMode == 2 ){
|
||||
// 从头开始
|
||||
this.playerObject.play();
|
||||
console.log("洗脑的单曲循环!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 播放到列表尾部,检查播放状态是否为0(单次播放列表)
|
||||
@ -133,12 +162,19 @@ class PlayerControl{
|
||||
// 播放列表完毕就清除事件监听器
|
||||
this.disableListener(this.playStatCheck());
|
||||
console.log("播放完毕,已清除事件监听。");
|
||||
return;
|
||||
} else {
|
||||
// 事件监听器未打开
|
||||
console.error("关闭失败,事件监听器未启用。");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Safe
|
||||
if(this.playerObject.ended == false) {
|
||||
console.log("安全模式| 歌曲未完播,安全执行函数");
|
||||
return;
|
||||
}
|
||||
// 切歌
|
||||
playnext();
|
||||
}
|
||||
@ -146,6 +182,7 @@ class PlayerControl{
|
||||
|
||||
// Title Control
|
||||
let TitleControl = new TitleStat(document.title);
|
||||
// Window OnBlur
|
||||
window.onblur = () => {
|
||||
console.log("您已离开播放器!");
|
||||
TitleControl.setScrollSpeed(500);
|
||||
@ -153,6 +190,7 @@ window.onblur = () => {
|
||||
TitleControl.startLoop();
|
||||
}
|
||||
|
||||
// Window OnFocus
|
||||
window.onfocus = () => {
|
||||
// document.title = originTitle;
|
||||
console.log("您已回到播放器!");
|
||||
@ -603,6 +641,7 @@ function InitPlayMode() {
|
||||
// About PlatMode
|
||||
RandomMode = 0;
|
||||
CyclePlayMode = 0;
|
||||
PlayerController = new PlayerControl();
|
||||
}
|
||||
|
||||
function changeRandButton() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user