// pages/player/player.js
var _animation; // 动画实体
var _animationIndex = 0; // 动画执行次数index(当前执行了多少次)
var _animationIntervalId = -1; // 动画定时任务id,通过setInterval来达到无限旋转,记录id,用于结束定时任务
const _ANIMATION_TIME = 5000; // 动画播放一次的时长ms
Page({
/**
* 页面的初始数据
*/
data: {
innerAudioContext:null,
animation: '',
state:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const innerAudioContext = wx.createInnerAudioContext()
this.setData({
innerAudioContext:innerAudioContext
})
//是否自动播放
innerAudioContext.autoplay = false
//音乐播放地址
innerAudioContext.src = 'https://ws.stream.qqmusic.qq.com/C4000019sdOL39DJB8.m4a?guid=448800619&vkey=06310DC86024C6BBB230E9AD2B2AD5EE0A19FEC0607617E30BA8B786C08F51AF68AC3414975C99B566636C20974DB3293F5EBFFC84D92047&uin=6973&fromtag=66'
//是否循环播放
innerAudioContext.loop = false
//
innerAudioContext.onPlay(() => {
this.setData({
state:true
})
})
innerAudioContext.onPause(()=>{
this.setData({
state:false
})
})
innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
})
},
play: function(){
var innerAudioContext = this.data.innerAudioContext
innerAudioContext.play()
//开始旋转
this.startAnimationInterval()
},
pause: function(){
this.data.innerAudioContext.pause()
this.stopAnimationInterval()
},
onReady: function () {
_animationIndex = 0;
_animationIntervalId = -1;
this.data.animation = '';
},
onShow: function () {
_animation = wx.createAnimation({
duration: _ANIMATION_TIME,
timingFunction: 'linear', // "linear","ease","ease-in","ease-in-out","ease-out","step-start","step-end"
delay: 0,
transformOrigin: '50% 50% 0'
})
},
/**
* 实现image旋转动画,每次旋转 120*n度
*/
rotateAni: function (n) {
_animation.rotate(120 * (n)).step()
this.setData({
animation: _animation.export()
})
},
/**
* 开始旋转
*/
startAnimationInterval: function () {
var that = this;
that.rotateAni(++_animationIndex); // 进行一次旋转
_animationIntervalId = setInterval(function () {
that.rotateAni(++_animationIndex);
}, _ANIMATION_TIME); // 每间隔_ANIMATION_TIME进行一次旋转
},
/**
* 停止旋转
*/
stopAnimationInterval: function () {
if (_animationIntervalId> 0) {
clearInterval(_animationIntervalId);
_animationIntervalId = 0;
}
}
})
没有合适的资源?快使用搜索试试~ 我知道了~
微信小程序精选源码亲测可用_云音乐在线静态小程序模板.zip
共43个文件
png:9个
json:8个
jpg:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 27 浏览量
2023-07-09
13:22:37
上传
评论
收藏 399KB ZIP 举报
温馨提示
微信小程序精选源码亲测可用_云音乐在线静态小程序模板.zip
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序精选源码亲测可用_云音乐在线静态小程序模板.zip (43个子文件)
云音乐在线静态小程序模板
2.jpg 40KB
fangwangyi
sitemap.json 191B
pages
index
index.wxml 2KB
index.js 224B
index.json 64B
index.wxss 916B
player
player.wxss 1KB
player.js 3KB
player.json 153B
player.wxml 854B
list
list.json 141B
list.wxss 3KB
list.js 929B
list.wxml 3KB
search
search.json 102B
search.wxss 472B
search.js 845B
search.wxml 236B
app.json 564B
project.config.json 2KB
app.js 48B
utils
util.js 472B
app.wxss 15B
components
navigation
navigation.wxml 834B
navigation.json 48B
navigation.js 1KB
navigation.wxss 962B
index.png 3KB
back.png 741B
navigation.wxs 272B
common
image
bfq.png 7KB
fenxiang.png 5KB
bsb.jpg 18KB
ting.png 8KB
singlecover.png 32KB
bofang.png 4KB
xgb.jpg 83KB
bf2.png 9KB
ycb.jpg 92KB
fang.png 9KB
logo.jpg 8KB
gq.jpg 38KB
rgb.jpg 22KB
共 43 条
- 1
资源评论
HappyGirl快乐女孩
- 粉丝: 1w+
- 资源: 4156
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功