Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use WeChat Mini Programs's backgroundAudioManager

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces WeChat Mini Programs's backgroundAudioManager how to use the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this WeChat Mini Programs's backgroundAudioManager how to use the article will have a harvest, let's take a look.

Wx.getBackgroundAudioManager ()

The basic library 1.2.0 is supported, and the lower version needs to be compatible.

Get the globally unique background audio manager backgroundAudioManager

BackgroundAudioManager

List of properties for the backgroundAudioManager object:

The attribute type indicates the length of the current audio of the read-only durationNumber (in s). It returns the current playback position of the currentTimeNumber audio (in s) only if there is a legitimate src, and whether the pausedBoolean is currently paused or stopped when there is a legitimate src. True indicates pause or stop, and false indicates that the data source of srcString audio is being played. The default is an empty string. When a new src is set. Playback will start automatically. Currently supported formats include M4a, aac, mp3, wav No startTimeNumber audio playback location (in s) No bufferedNumber audio buffer time point, only ensure that the content has been buffered from the current playback time point to this time point. Is the titleString audio title, which is used as the audio title of the native audio player. The sharing function in the native audio player and the title of the shared card will also use this value. No epnameString album name, sharing function in native audio player, card profile shared out, will also use this value. No singerString singer name, sharing function in native audio player, card profile shared out, will also use this value. No coverImgUrlString the cover image url, which is used as the background image of the native audio player. The sharing function in the native audio player, the picture and background of the shared cards will also be used. No, this value will also be used for webUrlString page links, sharing features in native audio players, and card profiles shared. No

List of methods for the backgroundAudioManager object:

Method parameters indicate that play playback pause pauses stop stops seekposition jumps to the specified location, unit sonCanplaycallback background audio enters playback state However, it is not guaranteed that the onPlaycallback background audio playback event onPausecallback background audio pause event onStopcallback background audio stop event onEndedcallback background audio natural playback end event onTimeUpdatecallback background audio playback progress update event onPrevcallback user click previous event (iOS only) onNextcallback user click next event (iOS only) onErrorcallback background audio playback error event onWaitingcallback audio loading event in the system music playback panel Triggered when audio needs to be stopped and loaded because of insufficient data

Errcode description

ErrCode description 10001 system error 10002 Network error 10003 File error 10004 format error-1 unknown error

Sample code:

Const backgroundAudioManager = wx.getBackgroundAudioManager () backgroundAudioManager.title ='at this moment 'backgroundAudioManager.epname =' at this moment 'backgroundAudioManager.singer =' Wang Feng 'backgroundAudioManager.coverImgUrl =' https://cache.yisu.com/upload/information/20220117/465/14324.jpg?max_age=2592000'backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' / / when src is set, it will automatically play about "Wechat short program" This is the end of the article on how to use the preface backgroundAudioManager. Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to use WeChat Mini Programs's backgroundAudioManager". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report