html5+c竞彩平台网投真人实体靠谱平台ss3制作音乐列表播放器源码
html5+css3制作音乐列表播放器,mp3音乐播放器列表ui工具特效,---在线演示// Designed by: Mauricio Bucardo// Original image: https://dribbble.com/shots/6957353-Music-Player-Widget"use strict";// add elemntsconst bgBody = ["#e5e7e9", "#ff4545", "#f8ded3", "#ffc382", "#f5eda6", "#ffcbdc", "#dcf3f3"];const body = document.body;const player = document.querySelector(".player");const playerHeader = player.querySelector(".player__header");const playerControls = player.querySelector(".player__controls");const playerPlayList = player.querySelectorAll(".player__song");const playerSongs = player.querySelectorAll(".audio");const playButton = player.querySelector(".play");const nextButton = player.querySelector(".next");const backButton = player.querySelector(".back");const playlistButton = player.querySelector(".playlist");const slider = player.querySelector(".slider");const sliderContext = player.querySelector(".slider__context");const sliderName = sliderContext.querySele竞彩平台ctor(".slider__name");const sliderTitle = sliderContext.querySelector(".slider__title");const sliderContent = slider.querySelector(".slider__content");const sliderContentLength = playerPlayList.length - 1;const sliderWidth = 100;let left = 0;let count = 0;let song = playerSongs[count];let isPlay = false;const pauseIcon = playButton.querySelector("img[alt = 'pause-icon']");const playIcon = playButton.querySelector("img[alt = 'play-icon']");const progres = player.querySelector(".progres"网投真人实体靠谱平台);const progresFilled = progres.querySelector(".progres__filled");let isMove = false;// creat functionsfunction openPlayer() { playerHeader.classList.add("open-header"); playerControls.classList.add("move"); slider.classList.add("open-slider"); }function closePlayer() { playerHeader.classList.remove("open-header"); playerControls.classList.remove("move"); slider.classList.remove("open-slider"); }function next() { if (count == sliderContentLength) { count = count; return } left += sliderWidth; left = Math.min(left, (sliderContentLength) * sliderWidth); sliderContent.style.transform = `translate3d(-${left}%, 0, 0)`; count++; changeSliderContext(); changeBgBody(); selectSong();}function back() { if (count == 0) { count = count return } left -= sliderWidth; left = Math.max(0, left); sliderContent.style.transform = `translate3d(-${left}%, 0, 0)`; count--;}function changeSliderContext() { sliderContext.style.animationName = "opacity"; sliderName.textContent = playerPlayList[count].querySelector(".player__title").textContent; sliderTitle.textContent = playerPlayList[count].querySelector(".player__song-name").textContent; if (sliderName.textContent.length > 16) { const textWrap = document.createElement("span"); textWrap.className = "text-wrap"; textWrap.innerHTML = sliderName.textContent + " " + sliderName.textContent; sliderName.innerHTML = ""; sliderName.append(textWrap); } if (sliderTitle.textContent.length >= 18) { const textWrap = document.createElement("span"); textWrap.className = "text-wrap"; textWrap.innerHTML = sliderTitle.textContent + " " + sliderTitle.textContent; sliderTitle.innerHTML = ""; sliderTitle.append(textWrap); }}function changeBgBody() { body.style.backgroundColor = bgBody[count];}function selectSong() { song = playerSongs[count]; for (const item of playerSongs) { if (item != song) { item.pause(); item.currentTime = 0; } } if (isPlay) song.play(); }function playSong() { if (song.paused) { song.play(); playIcon.style.display = "none"; pauseIcon.style.display = "block"; }else{ song.pause(); isPlay = false; playIcon.style.display = ""; pauseIcon.style.display = ""; } }function progresUpdate() { const progresFilledWidth = (this.currentTime / this.duration) * 100 + "%"; progresFilled.style.width = progresFilledWidth; if (this.duration == this.currentTime) { next(); } if (count == sliderContentLength && song.currentTime == song.duration) { playIcon.style.display = "block"; pauseIcon.style.display = ""; isPlay = false; }}function scurb(e) { // If we use e.offsetX, we have trouble setting the song time, when the mousemove is running const currentTime = ( (e.clientX - progres.getBoundingClientRect().left) / progres.offsetWidth ) * song.duration; song.currentTime = currentTime;}function durationSongs() { let min = parseInt(this.duration / 60); if (min < 10) min = "0" + min; let sec = parseInt(this.duration % 60); if (sec < 10) sec = "0" + sec; const playerSongTime = `${min}:${sec}`; this.closest(".player__song").querySelector(".player__song-time").append(playerSongTime);}changeSliderContext();// add eventssliderContext.addEventListener("click", openPlayer);sliderContext.addEventListener("animationend", () => sliderContext.style.animationName ='');playlistButton.addEventListener("click", closePlayer);nextButton.addEventListener("click", next);backButton.addEventListener("click", () => { back(); changeSliderContext(); changeBgBody(); selectSong();});playButton.addEventListener("click", () => { isPlay = true; playSong();});playerSongs.forEach(song => { song.addEventListener("loadeddata" , durationSongs); song.addEventListener("timeupdate" , progresUpdate); });progres.addEventListener("mousedown", (e) => { scurb(e); isMove = true; song.muted = true;});document.addEventListener("mousemove", (e) => isMove && scurb(e));document.addEventListener("mouseup", () => { isMove = false song.muted = false;});document.ondragstart = () => { return false};
- 最近发表
- 随机阅读
-
- CSS3文本效果text
- dedecms上传图片302error错误解决方法
- 个人博客网站常用优化内容方法
- 织梦DedeCMS图集发布图片调用外链方法
- PHP二维码在线制作生成网站源码
- WordPress动漫图片主题cxudy0.2下载
- CSS文本样式text
- dedecms文章栏目列表页标题增加序号
- 个人网站阿里云IPC备案10天办理完成
- wordpress移除后台外观下的编辑和仪表盘的模块
- WordPress动漫图片主题cxudy0.2下载
- WordPress多功能新闻积分商城主题LensNews2.2
- wordpress个人网站如何搬到电脑本地修改
- 烟雨开源图床系统源码v2.1下载
- 常用SEO命令/站长工具使用
- 小米米家扫拖机器人 M40 S 国补后立打7折:从高价到低价,实惠与实用并存
- 个人博客网站常用优化内容方法
- 生态环境部发布《2024中国生态环境状况公报》
- WordPress上传文件尺寸超过php.ini限制解决方法
- 个人博客html5雪花飘落代码JS特效下载
- 搜索
-
- 友情链接
-