提示:播放器部分代码未美化,有需要请自行编写
电脑端效果展示
<iframe allowfullscreen="true" data-mediaembed="csdn" frameborder="0" id="29Mj4aZU-1730614895362" src="https://live.csdn.net/v/embed/432368"></iframe>手机端效果展示
<iframe allowfullscreen="true" data-mediaembed="csdn" frameborder="0" id="UWhPXPKK-1730614756954" src="https://live.csdn.net/v/embed/432367"></iframe>CSS:
#musicPlayer {
position: fixed;
width: 300px;
height: 150px;
bottom: 20px;
right: 20px;
padding: 20px;
background-color: #444;
color: #fff;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
z-index: 1000;
cursor: move;
display: flex;
flex-direction: column;
align-items: center;
}
#title {
font-weight: bold;
font-size: 20px;
margin-bottom: 10px;
text-align: center;
}
#timeDisplay {
margin: 10px 0;
}
#progressBar {
width: 100%;
cursor: pointer;
}
#controls {
display: flex;
margin-top: 20px;
justify-content: space-between;
width: 100%;
}
button {
background-color: #666;
color: #fff;
border: none;
border-radius: 5px;
padding: 5px 10px;
cursor: pointer;
}
button:hover {
background-color: #888;
}
HTML:
<div id="musicPlayer">
<div id="title">
标签:播放器,function,const,isDragging,拖动,电脑,player,touch,document
From: https://blog.csdn.net/2402_87876495/article/details/143464887