seekbar

首次使用请先weexplus plugin add https://github.com/farwolf2010/seekbar 进度条,可以拖拽,因为weex对手势支持的不好,特此搬了一个原生的过来

属性

属性 作用
color 颜色
progress 进度
max 最大值
min 最小值

事件

名称 触发时机
start 开始执行拖拽时触发
stop 结束执行拖拽时触发
change 进度发生改变触发

demo

  1. <template>
  2. <div style="align-items: center">
  3. <head></head>
  4. <button text="ok" @click="show"></button>
  5. <seekbar @click="onstop" @start="onstart" @stop="onstop" @change="change" :max="total" :progress="progress" style="width:600px;height: 100px;" color="#238FFF"></seekbar>
  6. <text>{{v.value}}--{{total}}</text>
  7. <button text="seek" @click="seek"></button>
  8. </div>
  9. </template>
  10. <script>
  11. export default{
  12. props: {},
  13. data(){
  14. return {
  15. v:{},
  16. min:0,
  17. total:10000,
  18. progress:0,
  19. isPlaying:false,
  20. }
  21. },
  22. methods: {
  23. onstart(){
  24. let audio=weex.requireModule('audio')
  25. audio.pause()
  26. this.isPlaying=false
  27. },
  28. onstop(){
  29. // let audio=weex.requireModule('audio')
  30. //// audio.play('https://sur.nhc55555.com/uploads/2019-04/10/00b38343269dd25980bfa9a77f1a1584.mp3')
  31. //// audio.seek(this.v.value)
  32. // audio.seek(12000)
  33. // this.log('stop')
  34. // this.isPlaying=true
  35. this.seek()
  36. },
  37. seek(){
  38. let audio=weex.requireModule('audio')
  39. audio.seek(12000)
  40. },
  41. change(m){
  42. this.v=m
  43. // this.log(this.v)
  44. // this.progress=m.value
  45. },
  46. show(){
  47. // let pro=weex.requireModule('progress')
  48. this.isPlaying=true
  49. let audio=weex.requireModule('audio')
  50. audio.play('http://59.110.169.246/img/1.mp3')
  51. audio.setOnPlaying((res)=>{
  52. this.total=res.total
  53. // this.log(res)
  54. if(this.isPlaying){
  55. this.progress=res.current
  56. }
  57. })
  58. // pro.show()
  59. },
  60. onLoad(p){
  61. }
  62. },
  63. created(){
  64. }
  65. }
  66. </script>
  67. <style scoped>
  68. </style>