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