# MediaAudioPlayer wx.createMediaAudioPlayer()

Start from base library version 2.13.0. Please remaining backward compatible.

with Promise style call: Not supported

Mini Program plugin: Support

Create Media Audio Player Object MediaAudioPlayer Object that can be used to play a video decoder VideoDecoder Output audio.

# Return value

# MediaAudioPlayer

# Note

  • iOS 7.0.15 mediaAudioPlayer Play network video resources will appear audio Caton, local video does not have this problem, the next client version will be fixed.

# sample code

  // Create a video decoder, see createVideoDecoder file
  const videoDecoder = wx.createVideoDecoder()
  // Create Media Audio Player
  const mediaAudioPlayer = wx.createMediaAudioPlayer()
  // Activate video decoder.
  videoDecoder.start()
  // Start Player
  mediaAudioPlayer.start().then(() => {
    // Add a player audio source
    mediaAudioPlayer.addAudioSource(videoDecoder).then(res => {
      videoDecoder.getFrameData() // Recommendation in requestAnimationFrame Get every frame of video data
      console.log(res)
    })

    // Remove Player Audio Source
    mediaAudioPlayer.removeAudioSource (videoDecoder).then()
    // Stop the player
    mediaAudioPlayer.stop().then()
    // Destroy Player
    mediaAudioPlayer.destroy().then()
    // Set Player Volume
    mediaAudioPlayer.volume = 0.5
  })

# Complete demo (small game)

  • https://developers.weixin.qq.com/s/SF2duHmb7MjI
The translations are provided by WeChat Translation and are for reference only. In case of any inconsistency and discrepancy between the Chinese version and the English version, the Chinese version shall prevail.Incorrect translation. Tap to report.