1. 程式人生 > 程式設計 >微信小程式實現音樂播放頁面佈局

微信小程式實現音樂播放頁面佈局

本文例項為大家分享了微信小程式實現音樂播放頁面的佈局,供大家參考,具體內容如下

1.效果圖如下,點選播放按鈕後,光碟轉動,播放按鈕變為暫停按鈕;播放中點選暫停,光碟復位,暫停按鈕恢復為播放按鈕。

本文僅提供樣式佈局,其他具體響應不作介紹

微信小程式實現音樂播放頁面佈局

2.樣式佈局程式碼

wxml:

<view class="page_music">
  <view class='icon {{isPlay?"rotateAu":""}}' mode="widthFix">
   
  </view>
  <view class="tools">
    <view class="last" bindtap="last">
    </view>
    <view class='{{isPlay?"pause":"play"}}' bindtap="play">
    </view>
    <view class="next" bindtap="next">
    </view>
  </view>
  <view class="volume">
    <view class="volumeIcon">
    </view>
    <view class="sl">
    <slider min='0' max='10' step="1" value="0" bindchange="slide"/>
    </view>
  </view>
</view>

wxss:

.page_music{
  position: absolute;
  width: 100%;
  height: 80%;
}
.icon{
  position: relative;
  width: 500rpx;
  height: 500rpx;
  top:5%;
  left: 125rpx;
  background-image: url(""); /*放入光碟圖片*/
  background-size: 100% 100%;
  background-repeat:no-repeat;
  background-position: center;
}
.tools{
  position: relative;
  width: 80%;
  height: 10%;
  top: 10%;
  left: 10%;
}
.last{
  width: 100rpx;
  height: 100rpx;
  position: absolute;
  left: 0;
  top:0;
  background-image: url(""); /*放入上一首圖示*/
  background-size: 100% 100%;
  background-repeat:no-repeat;
  background-position: center;
}
.play{
  width: 100rpx;
  height: 100rpx;
  position: absolute;
  left: 42%;
  top:0;
  background-image: url(""); /*放入播放圖示*/
  background-size: 100% 100%;
  background-repeat:no-repeat;
  background-position: center;
}
.pause{
  width: 100rpx;
  height: 100rpx;
  position: absolute;
  left: 42%;
  top:0;
  background-image: url(""); /*放入暫停圖示*/
  background-size: 100% 100%;
  background-repeat:no-repeat;
  background-position: center;
}
.next{
  width: 100rpx;
  height: 100rpx;
  position: absolute;
  right: 0;
  top:0;
  background-image: url(""); /*放入下一首圖示*/
  background-size: 100% 100%;
  background-repeat:no-repeat;
  background-position: center;
}
.volume{
  position: relative;
  width: 80%;
  height: 10%;
  top: 20%;
  left: 10%;
}
.volumeIcon{
  position: absolute;
  left: 0;
  width: 80rpx;
  height: 80rpx;
  top:0;
  background-image: url(""); /*放入音量圖示*/
  background-size: 100% 100%;
  background-repeat:no-repeat;
  background-position: center;
}
.sl{
  position: absolute;
  right: 0;
  width: 80%;
  height: 100%;
  top: 0;
  background-image: url(""); /*放入滑動條背景圖片*/
  background-size: 100% 100%;
  background-repeat:no-repeat;
  background-position: center;
}
.rotateAu{
  animation: rotate 3s linear infinite;
 }
 @keyframes rotate{
  from{transform: rotate(0deg)}
  to{transform: rotate(360deg)}
 }

js:

Page({

  data:{
    isPlay:false,},play:function(e){
    if(this.data.isPlay==true)
    {
      this.setData({
        isPlay:false
      })
    }
    else
    {
      this.setData({
        isPlay:true
      })
    }
  }
})

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支援我們。