# AudioContext

AudioContext Example, you can use the wx.createAudioContext Get.

AudioContext adopt id With one. audio Component binding, the corresponding audio Component.

# method

# AudioContext.setSrc(string src)

Set the audio address

# AudioContext.play()

Play audio.

# AudioContext.pause()

Pause audio.

# AudioContext.seek(number position)

Jump to the specified location.

# sample code

<!-- audio.wxml -->
<audio  src="{{src}}" id="myAudio" ></audio>

<button type="primary" Bindtap = "audioPlay">play</button>
<button type="primary" Bindtap = "audiopause">Pause</button>
<button type="primary" bindtap="audio14">Set the current playback time to 14 seconds</button>
<button type="primary" Bindtap = "audioStart">Back to the beginning.</button>
// audio.js
Page({
  onReady (and) {
    // Use  wx.createAudioContext Obtain audio context context
    this.audioCtx = wx.createAudioContext('myAudio')
    this.audioCtx.setSrc('http://ws.stream.qqmusic.qq.with/M500001VfvsJ21xFqb.mp3guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46')
    this.audioCtx.play()
  },
  data: {
    src: ''
  },
  audioPlay () {
    this.audioCtx.play()
  },
  audioPause () {
    this.audioCtx.pause()
  },
  audio14 () {
    this.audioCtx.seek(14)
  },
  audioStart () {
    this.audioCtx.seek(0)
  }
})