Skip to content

Commit

Permalink
简化文件
Browse files Browse the repository at this point in the history
  • Loading branch information
Meekdai committed Oct 20, 2023
1 parent 3be0f4f commit 7d40031
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 183 deletions.
10 changes: 3 additions & 7 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="icon" href="https://meekdai.com/favicon.svg">
<title>Gmemp</title>
<link rel="stylesheet" href="./styles.css">
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Meekdai/Gmemp@main/docs/player.css"> -->
<link rel="stylesheet" href="./player.css">
</head>
<body>
<!-- Top Info -->
<div id="title">
<span id="track"></span>
<div id="timer">0:00</div>
<div id="duration">0:00</div>
<div id="post" style="display:none;"></div>
</div>

<!-- Controls -->
<div class="controlsOuter">
<div class="controlsInner">
<div id="loading"></div>
Expand All @@ -31,25 +30,22 @@
<div class="btn" id="volumeBtn"></div>
</div>

<!-- Progress -->
<div id="progressBar"></div>
<div id="progress"></div>
<canvas id="waveCanvas"></canvas>

<!-- Playlist -->
<div id="playlist">
<div id="list"></div>
</div>

<!-- Volume -->
<div id="volume" class="fadeout">
<div id="barFull" class="bar"></div>
<div id="barEmpty" class="bar"></div>
<div id="sliderBtn"></div>
</div>

<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/howler.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/gh/Meekdai/Gmemp@main/docs/player.js"></script> -->
<script src="./player.js"></script>
</body>
</html>
File renamed without changes.
57 changes: 29 additions & 28 deletions docs/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@ elms.forEach(function(elm) {
window[elm] = document.getElementById(elm);
});

let player;
let playNum=0;
let media="https://cdn.jsdelivr.net/gh/Meekdai/Gmemp@main/media/"
let requestJson="https://cdn.jsdelivr.net/gh/Meekdai/Gmemp@main/docs/memp.json"
// let requestJson="https://music.meekdai.com/memp.json"

let request=new XMLHttpRequest();
request.open("GET",requestJson);
request.responseType='text';
request.send();
request.onload=function(){
jsonData=JSON.parse(request.response);
console.log(jsonData);

if(window.location.hash!=''){
try{
playNum=parseInt(window.location.hash.slice(1));
}
catch{
playNum=jsonData.length-1 //默认最近添加的
}
}
else{playNum=jsonData.length-1} //默认最近添加的

player = new Player(jsonData);
}

/**
* Player class containing the state of our playlist and where we are in it.
* Includes all methods for playing, skipping, updating the display, etc.
Expand All @@ -17,7 +44,6 @@ let Player = function(playlist) {
// Display the title of the first track.
track.innerHTML = playlist[this.index].title;
document.querySelector("body").style.backgroundImage = "url('" +media+ encodeURI(playlist[this.index].pic) + "')";
console.log("url(" +media+ encodeURI(playlist[this.index].pic) + ")");
post.innerHTML = playlist[this.index].article;

// Setup the playlist display.
Expand Down Expand Up @@ -280,33 +306,6 @@ Player.prototype = {
}
};

let player;
let playNum=0;
let media="https://cdn.jsdelivr.net/gh/Meekdai/Gmemp@main/media/"
// let requestJson="https://cdn.jsdelivr.net/gh/Meekdai/Gmemp@main/memp.json"
let requestJson="https://music.meekdai.com/memp.json"

let request=new XMLHttpRequest();
request.open("GET",requestJson);
request.responseType='text';
request.send();
request.onload=function(){
jsonData=JSON.parse(request.response);
console.log(jsonData);

if(window.location.hash!=''){
try{
playNum=parseInt(window.location.hash.slice(1));
}
catch{
playNum=jsonData.length-1 //默认最近添加的
}
}
else{playNum=jsonData.length-1} //默认最近添加的

player = new Player(jsonData);
}

// Bind our player controls.
playBtn.addEventListener('click', function() {
player.play();
Expand Down Expand Up @@ -403,3 +402,5 @@ function draw() {
x += barWidth + 1;
}
}

console.log("\n %c Gmemp v1.0 %c https://github.com/Meekdai/Gmemp \n", "color: #fff; background-image: linear-gradient(90deg, rgb(47, 172, 178) 0%, rgb(45, 190, 96) 100%); padding:5px 1px;", "background-image: linear-gradient(90deg, rgb(45, 190, 96) 0%, rgb(255, 255, 255) 100%); padding:5px 0;");
148 changes: 0 additions & 148 deletions docs/siriwave.js

This file was deleted.

0 comments on commit 7d40031

Please sign in to comment.