# 10.3 音乐播放器(Music player)

# 实例 :

# 基础用法

<template>
  <div class="demo">
    <dof-minibar
      :left-button="leftButton"
      title="音乐播放器"
      text-color="#ffffff"
      background-color="rgba(38,122,255,1)"
      @dofMinibarLeftButtonClicked="back"
    ></dof-minibar>
    <div class="content-container">
      <dof-music-player
        :volume="30"
        :min="0"
        :max="100"
        :play="playFlag"
        :title="'早间新闻'"
        @dofVolumeChanged="dofVolumeChanged"
        @dofPlayClicked="dofPlayClicked"
        @dofNextClicked="dofNextClicked"
      ></dof-music-player>
      <div class="h-10"></div>
      <dof-music-player
        :volume="50"
        :min="0"
        :max="100"
        :play="!playFlag"
        :title="'早间新闻到底是怎么'"
        @dofVolumeChanged="dofVolumeChanged"
        @dofPlayClicked="dofPlayClicked"
        @dofNextClicked="dofNextClicked"
      ></dof-music-player>
      <div class="h-10"></div>
      <dof-music-player
        :volume="80"
        :min="0"
        :max="100"
        :play="playFlag"
        :title="'早间新闻到底是怎么进行一场场播报的'"
        @dofVolumeChanged="dofVolumeChanged"
        @dofPlayClicked="dofPlayClicked"
        @dofNextClicked="dofNextClicked"
      ></dof-music-player>
    </div>
  </div>
</template>

<script>
import { DofMinibar, DofMusicPlayer } from 'dolphin-weex-ui'
const modal = weex.requireModule('modal')
export default {
  components: {
    DofMinibar,
    DofMusicPlayer
  },
  data: () => ({
    leftButton: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/header/icon_back_white@3x.png',
    playFlag: true
  }),
  created() {},
  mounted() {},
  computed: {},
  methods: {
    dofVolumeChanged(val) {
      modal.toast({
        message: val
      })
    },
    dofPlayClicked(type) {
      modal.toast({
        message: type
      })
    },
    dofNextClicked() {
      modal.toast({
        message: 'Next Clicked'
      })
    }
  }
}
</script>

<style scoped>
.demo {
  background-color: #f9f9f9;
}
.content-container {
  padding: 32px;
}

.h-10 {
  width: 100%;
  height: 20px;
}
</style>



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

# Attributes

参数 说明 类型 默认值 是否必须
title 标题 String - Y
play true 播放/false 暂停 Boolean false Y
volume 音量大小 Number 50 Y
min 音量显示最小值 Number 0 Y
max 音量显示最大值 Number 100 Y
step 步长 number 1 -
theme 主题颜色,可选值为:brand purple blue-purple blue cyan yellow orange orange-red gray-offline string brand -
track-height 滑动条轨道高度 number 40 -
track-color 滑动条轨道颜色 string #f2f2f2 -
bar-color 滑动条滚动条颜色 string - -
button-size 滑动条按钮尺寸 number 24 -
button-color 滑动条按钮颜色 string #ffffff -
readonly 滑动条是否只读 boolean false -

# Events

事件名 说明 回调参数
dofVolumeChanged 音量变化时触发 volume
dofPlayClicked 点击暂停播放时触发 pause 暂停 play 播放
dofNextClicked 点击下一首时触发 -
Last Updated: 9/30/2022, 9:49:31 AM