当前位置: 首页 > news >正文

网站没有设置关键词滁州市城市建设投资有限公司网站

网站没有设置关键词,滁州市城市建设投资有限公司网站,西安装修公司哪家口碑最好,信息流广告二级代理微信小程序实现一个音乐播放器的功能 要求代码实现wxml 文件wxss 文件js文件 解析 要求 1.页面包含一个音乐列表#xff0c;点击列表中的音乐可以播放对应的音乐。 2.播放中的音乐在列表中有标识#xff0c;并且可以暂停或继续播放。 3.显示当前音乐的播放进度和总时长#… 微信小程序实现一个音乐播放器的功能 要求代码实现wxml 文件wxss 文件js文件 解析 要求 1.页面包含一个音乐列表点击列表中的音乐可以播放对应的音乐。 2.播放中的音乐在列表中有标识并且可以暂停或继续播放。 3.显示当前音乐的播放进度和总时长并可以拖动进度条调整播放进度。 4.点击切换按钮可以切换到下一首音乐。 5.点击循环按钮可以切换音乐的播放模式单曲循环、列表循环、随机播放。 代码实现 wxml 文件 view classcontainerscroll-view scroll-y classmusic-listview wx:for{{ musicList }} wx:key{{ index }} classmusic-item bindtaponMusicTap data-index{{ index }}view classmusic-name{{ item.name }}/viewview classmusic-artist{{ item.artist }}/view/view/scroll-viewaudio idaudio src{{ currentMusic.src }} bindtimeupdateonTimeUpdate bindendedonEnded/audioview classplayerview classcontrolsbutton classcontrol-btn bindtaponPrev上一首/buttonbutton classcontrol-btn bindtaponPlayOrPause{{ playing ? 暂停 : 播放 }}/buttonbutton classcontrol-btn bindtaponNext下一首/buttonbutton classcontrol-btn bindtaponChangeMode模式/button/viewview classprogresstext{{ currentTime }}/textslider max{{ duration }} value{{ currentPosition }} bindchangeonSliderChange /text{{ durationStr }}/text/view/view /view wxss 文件 .container {padding: 20rpx; }.music-list {height: 300rpx; }.music-item {padding: 10rpx;border-bottom: 1rpx solid #eee;text-align: left; }.player {margin-top: 20rpx;display: flex;flex-direction: column;align-items: center; }.controls {display: flex;justify-content: space-around;width: 100%;margin-bottom: 10rpx; }.control-btn {background-color: #009688;color: #fff;padding: 10rpx 20rpx;border-radius: 4rpx; }progress {display: flex;align-items: center; }.slider {flex: 1;margin: 0 10rpx; }js文件 Page({data: {musicList: [{ name: 歌曲1, artist: 歌手1, src: music1.mp3 },{ name: 歌曲2, artist: 歌手2, src: music2.mp3 },// 更多音乐...],currentMusic: {},playing: false,duration: 0,currentPosition: 0,currentTime: 00:00,durationStr: 00:00,playMode: 0, // 0: 列表循环1: 单曲循环2: 随机播放},onMusicTap(e) {const index e.currentTarget.dataset.index;const music this.data.musicList[index];this.setData({currentMusic: music,playing: true,});this.playMusic();},onPlayOrPause() {if (this.data.playing) {this.pauseMusic();} else {this.playMusic();}},playMusic() {const audio this.selectComponent(#audio);audio.play();this.setData({playing: true,});},pauseMusic() {const audio this.selectComponent(#audio);audio.pause();this.setData({playing: false,});},onPrev() {let currentIndex this.data.musicList.findIndex(item item.src this.data.currentMusic.src);if (currentIndex 0) {currentIndex this.data.musicList.length - 1;} else {currentIndex--;}const music this.data.musicList[currentIndex];this.setData({currentMusic: music,playing: true,});this.playMusic();},onNext() {let currentIndex this.data.musicList.findIndex(item item.src this.data.currentMusic.src);if (currentIndex this.data.musicList.length - 1) {currentIndex 0;} else {currentIndex;}const music this.data.musicList[currentIndex];this.setData({currentMusic: music,playing: true,});this.playMusic();},onTimeUpdate(e) {const duration e.detail.duration;const currentPosition e.detail.currentTime;const currentTime this.formatTime(currentPosition);const durationStr this.formatTime(duration);this.setData({duration: duration,currentPosition: currentPosition,currentTime: currentTime,durationStr: durationStr,});},onEnded() {if (this.data.playMode 1) {// 单曲循环const audio this.selectComponent(#audio);audio.seek(0);audio.play();} else {this.onNext();}},onSliderChange(e) {const value e.detail.value;const audio this.selectComponent(#audio);audio.seek(value);},onChangeMode() {let playMode this.data.playMode;playMode (playMode 1) % 3;this.setData({playMode: playMode,});},formatTime(time) {const minutes Math.floor(time / 60);const seconds Math.floor(time % 60);const minuteStr minutes 10 ? 0 minutes : minutes;const secondStr seconds 10 ? 0 seconds : seconds;return minuteStr : secondStr;}, }); 解析 其中onPrev() 和 onNext() 函数实现了切换到上一首和下一首音乐的逻辑。通过 findIndex() 函数找到当前音乐在列表中的位置然后根据播放模式计算出下一首或上一首音乐的位置更新当前音乐并播放。 onTimeUpdate() 函数实现了更新播放进度的逻辑通过 detail 参数获取音频的总时长和当前播放进度并格式化成 00:00 的形式更新页面数据。 onEnded() 函数实现了音乐播放结束的逻辑根据当前的播放模式决定是单曲循环还是切换到下一首音乐。 onSliderChange() 函数实现了调整播放进度的逻辑通过 seek() 函数跳转到指定的时间点。 onChangeMode() 函数实现了切换播放模式的逻辑通过取余操作循环切换三种播放模式。 到这里也就结束了希望对您有所帮助。
http://www.zqtcl.cn/news/410820/

相关文章:

  • 单位建设网站装修公司需要什么资质
  • 做做做网站做网站赚外快
  • 网站备案后应该做什么网站流量监测
  • 开发网站用什么语言做名片的网站叫什么来着
  • 织梦做网站好不好iis中的网站启动不了
  • 临汾住房与城乡建设厅网站迎访问中国建设银行网站_
  • 织梦做的网站首页幻灯片怎么不能显示北大青鸟网站建设课程
  • 做淘客的网站有哪些延安市住建建设网站
  • 南京林业大学实验与建设网站现在都用什么软件搜索附近的人
  • 建站系统wordpress下载亚马逊雨林十大恐怖生物
  • 凡科网做网站怎么样专业团队电影
  • 有什么有趣的网站移动网站排名怎么做
  • 深圳网站建设专家wordpress 4.5下载地址
  • 网站建设公司公司我我提供一个平台wordpress如何去版权信息
  • seo怎么给网站做外链受欢迎的网站建设教程
  • 网站建设使用多语言河南电商网站设计
  • 网站搭建有免费的吗网站地图生成代码
  • 建设公司网站要注意什么投资小利润高的小生意
  • 网站建设需要做哪些工作做胃镜需那好天津津门网站A
  • 做网站申请域名的流程辽宁省工程造价网
  • 网站系统维护一般多长时间金华高端网站设计
  • 做网站公司销售开场白企业网站规划与开发
  • 兰州新区建站不锈钢网站建设
  • 淘宝小网站怎么做的电商网站有哪些
  • 哪些网站可以做画赚钱wordpress go跳转页
  • 怎么做新网站上线通稿深圳罗湖区网站建设公司
  • php 企业网站做网站可以赚钱吗
  • 局域网视频网站建设点播系统长沙3合1网站建设价格
  • 静态网站 服务器合肥做个网站什么价格
  • 宁阳网站设计家电网站设计方案