再爱‘小播‘【audio播放器资源】
本帖最后由 亚伦影音工作室 于 2024-4-16 19:10 编辑 <br /><br /><style>#bfqbg {margin: 0px 0px;
width:100%;
height: 120px;
background:#000 url()no-repeat 0px -200px/cover;
border-radius:2px;
position: relative;overflow: hidden;
z-index: 123;
}
#tp{position:absolute;height:106px;width:106px;bottom:8px; left:8px;}
#tp img{height: 100%;width: 100%;}
#dt{position: absolute;bottom:460px; left:0%;width: 100%;height: 120px;opacity: 1;}
#dt img{width: 100%;}
audio {position:absolute;top:80px;left:70px;z-index: 50;
width: 90%;
height: 40px;
outline: none;
filter: invert(180);
}
audio::-webkit-media-controls-enclosure {
background:transparent ;
border-radius: 4px;
}
.media-controls-container,
.media-controls-container * {
background: rgb(129, 73, 200);
//滤镜反转为 rgba(0, 162, 255, 1);rgba(255, 93, 0, 0.8)#7eb637
border-radius: 4px;
}
audio::-webkit-media-controls-current-time-display {
order: 1; //设置弹性盒对象元素的顺序
color: #ffffff;
text-shadow: unset;
}
audio::-webkit-media-controls-time-remaining-display {
order: 2;
color: #000000;
text-shadow: unset;
}
#bt{ width: 500px; height: 50px;color: #ffffff; position: absolute; left:120px;top:10px;font-size: 16px; font-family:仿宋;z-index: 21;}
</style>
<div id="bfqbg">
<div id="dt"><img id="Img" src="https://pic.imgdb.cn/item/644e2e6c0d2dde5777e7add9.gif" /></div>
<img id="tp" src="https://pic.imgdb.cn/item/6574fa4dc458853aefca81ff.jpg" alt="" />
<div id="bt">我已不是当初模样-魏佳艺</div>
<audioid="aud" loop controls autoplay>
<source src="https://lx-sycdn.kuwo.cn/6f2ffe35f23aab44be107e5bbf73589f/661e2efa/resource/n2/25/54/2366323139.mp3?from=vip" type="audio/mp3" /></audio>
<divclass="lrc">
<ul id="ullrc">
</ul>
</div>
</div>
<style type="text/css">
.lrc{z-index: 20;
width: 80%;bottom:-18px; left:15%;
height: 100px;
overflow: hidden;
display: block;position: absolute;
margin: 0 auto;}
.lrc #ullrc{
width: 700px;
padding: 0;list-style: none;transition: 0.3s all ease;
margin: 0;}
/*歌词普通样式*/
.lrc #ullrc li{
height: 70px;
line-height: 60px;
font-family:仿宋;
font-size: 0px;
color: #000078;
font-weight: normal;
transition: .3s all ease;/*一定要加上不然看着突兀*/
list-style-type: none;
text-align: center;display: block;
width: 100%;
margin: 0 auto;}
/*动态歌词样式*/
.lrc #ullrc li.active{
font-size: 25px;
color: #ffffff;}
</style>
<script >
var lrc = `我已不是当初模样
演唱:魏佳艺
作词:灵凡
作曲:木易
编曲:漠心藤
吉他:漠心藤
我已不是当初模样
混音:一楠先生
制作人:亚伦
封面设计:亚伦
艺人统筹:蓝舟
监制:Super
出品人:亚伦
OP/SP:影音工作室
我一路走一路回头望
回首往事只剩一身沧桑
停不下脚步渡不过心中的迷惘
慢慢遗忘最初信仰
我不知已热泪过几场
再多的苦累只能心里藏
我背上了行囊哪是我的避风港
谁能让我不再悲伤
我已不是当初模样现实将梦埋葬
每一步都走的踉踉跄跄
前半生已过为了碎银几两
深夜匆匆忙忙走在路上
我已不是当初模样 生活将梦遗忘
这事态炎凉我慢慢品尝
前半生已过我却还在流浪
到底哪里才会是我的梦乡
我不知已热泪过几场
再多的苦累只能心里藏
我背上了行囊哪是我的避风港
谁能让我不再悲伤
我已不是当初模样现实将梦埋葬
每一步都走的踉踉跄跄
前半生已过为了碎银几两
深夜匆匆忙忙走在路上
我已不是当初模样 生活将梦遗忘
这事态炎凉我慢慢品尝
前半生已过我却还在流浪
到底哪里才会是我的梦乡
我已不是当初模样现实将梦埋葬
每一步都走的踉踉跄跄
前半生已过为了碎银几两
深夜匆匆忙忙走在路上
我已不是当初模样 生活将梦遗忘
这事态炎凉我慢慢品尝
前半生已过我却还在流浪
到底哪里才会是我的梦乡
`;
function $(id) {return document.getElementById(id);
}//这样写以后getid方便
function getLrcArray() {
var parts = lrc.split("\n");
for (let index = 0; index < parts.length; index++) {
parts = getLrcObj(parts);
}
return parts;
function getLrcObj(content) {
var twoParts = content.split("]");
var time = twoParts.substr(1);
var timeParts = time.split(":");
var seconds = +timeParts;
var min = +timeParts;
seconds = min * 60 + seconds;
var words = twoParts;
return{
seconds: seconds,
words: words,
};
}
}
var lrcArray = getLrcArray();
function inputLrc() {
for (let index = 0; index < lrcArray.length; index++) {
var li = document.createElement("li");
li.innerText = lrcArray.words;
$("ullrc").appendChild(li);
}
}
inputLrc();
function setPosition() {
var index = getLrcIndex();
if (index == -1) {
return;
}
var lrc_li_height = 70, lrc_ul_height = 60;
var top = index * lrc_li_height + lrc_li_height / 2 - lrc_ul_height / 2;
if (top < 0) {top = 0;}$("ullrc").style.marginTop = -top + "px";
var activeLi = $("ullrc").querySelector(".active");
if(activeLi){
activeLi.classList.remove("active");}
$("ullrc").children.classList.add("active");
}
var turn = 0;
function getLrcIndex(){
var time = $("aud").currentTime + turn;for (var index = 0; index < lrcArray.length; index++) {
if (lrcArray.seconds > time) {
return index - 1;
}
}
}
$("aud").ontimeupdate = setPosition;
</script>
<script>
if ('getContext' in document.createElement('canvas')) {
HTMLImageElement.prototype.play = function() {
if (this.storeCanvas) {
// 移除存储的canvas
this.storeCanvas.parentElement.removeChild(this.storeCanvas);
this.storeCanvas = null;
// 透明度还原
image.style.opacity = '';
}
if (this.storeUrl) {
this.src = this.storeUrl;
}
};
HTMLImageElement.prototype.stop = function() {
var canvas = document.createElement('canvas');
// 尺寸
var width = this.width, height = this.height;
if (width && height) {
// 存储之前的地址
if (!this.storeUrl) {
this.storeUrl = this.src;
}
// canvas大小
canvas.width = width;
canvas.height = height;
// 绘制图片帧(第一帧)
canvas.getContext('2d').drawImage(this, 0, 0, width, height);
// 重置当前图片
try {
this.src = canvas.toDataURL("image/gif");
} catch(e) {
// 跨域
this.removeAttribute('src');
// 载入canvas元素
canvas.style.position = 'absolute';
// 前面插入图片
this.parentElement.insertBefore(canvas, this);
// 隐藏原图
this.style.opacity = '0';
// 存储canvas
this.storeCanvas = canvas;
}
}
};
}
var image= document.getElementById("Img");
let mState = () => aud.paused ? image.stop():image.play();
aud.addEventListener('play', () => mState());
aud.addEventListener('pause', () => mState());
</script>
听歌听歌{:4_187:} 感谢分享 好漂亮,这个的效果比前面那个更好呢。
亚伦老师一路在深入研究,很赞{:4_199:}
页:
[1]