uniapp sound reminder, vibration reminder, voice broadcast plug-in Ba-Beep

Introduction ( download address )

Ba-Beep is a plug-in for uniapp that provides sound prompts and vibration prompts, such as operation prompts (scanning codes, reading cards, printing, pressing keys, etc.). Simple voice broadcast function can also be realized.

  • Support sound (by default there are beep, numbers, English letters, welcome, thank you, etc., which can be customized)
  • Support vibration (can customize the vibration effect)
  • Support voice broadcast (content can be customized by contacting the author, or added by oneself)
  • Supported audio formats are mp3, wav, ogg, 3gp, AAC, AMR, FLAC, MIDI, etc.

Instructions

scriptIntroduce components in

	const beep = uni.requireNativePlugin('Ba-Beep')

scriptcalled in

		methods: {
    
    
			play(name = this.name) {
    
     //播放声音
				beep.play({
    
    
						beepName: name,//音频资源名称,参照“音频资源配置”
					},
					(res) => {
    
    
						console.log(res)
						uni.showToast({
    
    
							title: res.msg,
							icon: "none",
							duration: 3000
						})
					});
			},
			playVibrate() {
    
     //震动
				//let params = {};//默认 500
				let params = {
    
    
					repeat: 0,//重复 -1:表示不重复 0:循环的震动 >1:表示从哪里开始重复
					pattern: [500, 200, 500, 100]//震动规则,传递一个整型数组作为关闭和开启震动的持续时间,以毫秒为单位。第一个值表示等待震动开启的毫秒数,下一个值表示保持震动的毫秒数,这个序列值交替表示震动关闭和开启的毫秒数
				}; //自定义规则
				
				beep.playVibrate(params,
					(res) => {
    
    
						console.log(res)
						uni.showToast({
    
    
							title: res.msg,
							icon: "none",
							duration: 3000
						})
					});
			},
			cancelVibrate() {
    
     //取消震动
				beep.cancelVibrate(
					(res) => {
    
    
						console.log(res)
						uni.showToast({
    
    
							title: res.msg,
							icon: "none",
							duration: 3000
						})
					});
			},
		}

Audio resource configuration

Voice prompt, voice broadcast, supported audio formats are mp3, wav, ogg, 3gp, AAC, AMR, FLAC, MIDI and so on.

Note: After the configuration is changed, the base needs to be remade to take effect. It is recommended to configure it in advance.

  • Default resources : refer to the "Default Resource Comparison Table" below

    Default resource comparison table

Resource Name illustrate
‘beep’ beep sound
‘welcome’ welcome
‘thanks’ Thanks
‘_0’ Numbers 0~9, the name is underline + corresponding number, such as 0 is "_0"
‘_a’ English letters A~Z, the name is underlined + corresponding lowercase letters, such as A is "_a"
  • Custom resources : the audio resources used are placed in the "nativeplugins\Ba-Beep\android\res\raw" directory

insert image description here

method list

name illustrate
play Play prompt tone, voice broadcast
playVibrate shock
cancelVibrate cancel vibration

Play sound play method parameters

attribute name type Defaults illustrate
beepName String ‘beep’ resource file path

Vibration playVibrate method parameters

attribute name type Defaults illustrate
repeat Number 0 Repeat -1: Indicates no repetition 0: Cycle vibration > 1: Indicates where to start repeating
pattern Array [] Vibration rules, such as "[500,100,500,100]"

Vibration rule : Pass an integer array as the duration of turning off and on the vibration, in milliseconds. The first value represents the number of milliseconds to wait for the vibration to turn on, the next value represents the number of milliseconds to keep the vibration on, and this sequence value alternately represents the number of milliseconds to turn the vibration off and on.

Series plug-in

Image selection plugin Ba-MediaPicker ( documentation )

Image editing plugin Ba-ImageEditor ( documentation )

File picker plugin Ba-FilePicker ( documentation )

Application message notification plugin Ba-Notify ( documentation )

Apply the unread badge plugin Ba-Shortcut-Badge ( documentation )

Applying the Ba-Autoboot plugin ( documentation )

Scan code native plug-in (millisecond level, support multi-code) Ba-Scanner-G ( documentation )

Native plug-in for scanning code - new (can customize the interface version arbitrarily; support continuous scanning code; support setting scanning code format) Ba-Scanner ( documentation )

Dynamically modify the status bar, navigation bar background color, font color plug-in Ba-AppBar ( documentation )

Native sqlite local database management Ba-Sqlite ( documentation )

Android keep alive plugin Ba-KeepAlive ( documentation )

Android shortcut (desktop long press app icon) Ba-Shortcut ( documentation )

Custom Image Watermark Ba-Watermark ( documentation )

Video compression plugin Ba-VideoCompressor ( documentation )

Dynamically switch application icons and names (such as New Year, National Day, etc.) Ba-ChangeIcon ( documentation )

Native Toast pop-up prompt (can penetrate all interfaces) Ba-Toast ( documentation )

Image graffiti, brush Ba-ImagePaint ( documentation )

pdf Read Ba-Pdf ( documentation )

Guess you like

Origin blog.csdn.net/u013164293/article/details/127676467