您现在的位置是:mp3音乐a决胜巅峰下载安装加拿大28预测网-开奖lpc预测pp界面js设计模板 >>正文
mp3音乐a决胜巅峰下载安装加拿大28预测网-开奖lpc预测pp界面js设计模板
惶惶不可终日网52人已围观
简介music-app-vue-js,点击按钮可实现音乐的播放,音乐app界面设计模板,音乐app视图JS(带声音)---在线演示// JavaScript Time!var app = new Vue(...
music-app-vue-js,点击按钮可实现音乐的播放,音乐app界面设计模板,音乐app视图JS(带声音)
---在线演示
// JavaScript Time!var app = new Vue({ el: "#app", data: { audio: "", imgLoaded: false, currentlyPlaying: false, currentlyStopped: false, currentTime: 0, checkingCurrentPositionInTrack: "", trackDuration: 0, currentProgressBar: 0, isPlaylistActive: false, currentSong: 0, debug: false, musicPlaylist: [ { title: "andy", artist: "阿杜", url: "http://img.bokequ.com/music/andy.mp3", image: "http://www.bokequ.com/show/yinyue/2/images/andy.jpg" }, { title: "留什么给你", artist: "孙楠", url: "http://img.bokequ.com/music/geini.mp3", image: "http://www.bokequ.com/show/yinyue/2/images/3.jpg" }, { title: "在他乡", artist: "水年木华", url: "http://img.bokequ.com/music/zaitaxiang.mp3", image: "https://img4.kuwo.cn/star/albumcover/120/93/5/2858315927.jpg" }, { title: "黄梅戏", artist: "慕容晓晓", url: "http://www.bokequ.com/show/yinyue/3/audio/huangmeixi.mp3", 加决胜巅峰下载安装拿大28预测网-开奖lpc预测 image: "http://www.bokequ.com/show/yinyue/2/images/huangmeixi.jpg" }], audioFile: "" }, mounted: function () { this.changeSong(); this.audio.loop = false; }, filters: { fancyTimeFormat: function (s) { return (s - (s %= 60)) / 60 + (9 < s ? ":" : ":0") + s; } }, methods: { togglePlaylist: function () { this.isPlaylistActive = !this.isPlaylistActive; }, nextSong: function () { if (this.currentSong < this.musicPlaylist.length - 1) this.changeSong(this.currentSong + 1); }, prevSong: function () { if (this.currentSong > 0) this.changeSong(this.currentSong - 1); }, changeSong: function (index) { var wasPlaying = this.currentlyPlaying; this.imageLoaded = false; if (index !== undefined) { this.stopAudio(); this.currentSong = index; } this.audioFile = this.musicPlaylist[this.currentSong].url; this.audio = new Audio(this.audioFile); var localThis = this; this.audio.addEventListener("loadedmetadata", function () { localThis.trackDuration = Math.round(this.duration); }); this.audio.addEventListener("ended", this.handleEnded); if (wasPlaying) { this.playAudio(); } }, isCurrentSong: function (index) { if (this.currentSong == index) { return true; } return false; }, getCurrentSong: function (currentSong) { return this.musicPlaylist[currentSong].url; }, playAudio: function () { if ( this.currentlyStopped == true && this.currentSong + 1 == this.musicPlaylist.length) { this.currentSong = 0; this.changeSong(); } if (!this.currentlyPlaying) { this.getCurrentTimeEverySecond(true); this.currentlyPlaying = true; this.audio.play(); } else { this.stopAudio(); } this.currentlyStopped = false; }, stopAudio: function () { this.audio.pause(); this.currentlyPlaying = false; this.pausedMusic(); }, handleEnded: function () { if (this.currentSong + 1 == this.musicPlaylist.length) { this.stopAudio(); this.currentlyPlaying = false; this.currentlyStopped = true; } else { this.currentlyPlaying = false; this.currentSong++; this.changeSong(); this.playAudio(); } }, onImageLoaded: function () { this.imgLoaded = true; }, getCurrentTimeEverySecond: function (startStop) { var localThis = this; this.checkingCurrentPositionInTrack = setTimeout( function () { localThis.currentTime = localThis.audio.currentTime; localThis.currentProgressBar = localThis.audio.currentTime / localThis.trackDuration * 100; localThis.getCurrentTimeEverySecond(true); }.bind(this), 1000); }, pausedMusic: function () { clearTimeout(this.checkingCurrentPositionInTrack); }, toggleDebug: function () { this.debug = !this.debug; document.body.classList.toggle('debug'); } }, watch: { currentTime: function () { this.currentTime = Math.round(this.currentTime); } }, beforeDestroy: function () { this.audio.removeEventListener("ended", this.handleEnded); this.audio.removeEventListener("loadedmetadata", this.handleEnded); clearTimeout(this.checkingCurrentPositionInTrack); } });100%响应,
这是一款音乐js代码,适用于
Tags:
相关文章
css中position属性定位:absolute与relative
mp3音乐a决胜巅峰下载安装加拿大28预测网-开奖lpc预测pp界面js设计模板定位层是由html元素(标签)形成的一个特殊的box盒子。其重点在于“定位”,而html元素(标签)的定位方式由css来控制。通常情况下,html元素(标签)默认的定位方式叫作“静态定位”,存在于普通...
阅读更多
wordpress简约清新范博客主题Pinghsu
mp3音乐a决胜巅峰下载安装加拿大28预测网-开奖lpc预测pp界面js设计模板Pinghsu 是一款以前端性能优化为出发点而制作的 Typecho 主题,同时又兼顾设计美学和视觉传达。主题命名取自作者姓名和其女朋友姓名的最后一个字的港式英文,挣扎于 Hsuping 还是 Pin...
阅读更多
wordpress个人网站如何搬到电脑本地修改
mp3音乐a决胜巅峰下载安装加拿大28预测网-开奖lpc预测pp界面js设计模板有时候wordpress更换模板时,需要修改的地方很多,而且在线修改不是很好。只能把它移动到电脑本地进行修改了。这样修改好就可以直接套用到网站上了。1、通过服务器控制面板或FTP整站打包,发送到你已经...
阅读更多