iOS Question Play Beep Sound - Revisited

aminoacid

Active Member
Licensed User
Longtime User
The following very useful code was published in another post. Is it possible to pass the SystemSoundID (1302 in this case) to the Sub as a parameter?

B4X:
Sub PlayBeep
    Dim NativeMe As NativeObject = Me
    NativeMe.RunMethod("beep", Null)
End Sub

#If ObjC
#import <AVFoundation/AVAudioPlayer.h>
- (void) beep {
  AudioServicesPlaySystemSound(1302);
}
#End If
 

Semen Matusovskiy

Well-Known Member
Licensed User
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
I know this is old, but I found this thread from Google, and it did not look like it was answered.

Here is the answer:

B4X:
#If ObjC
#import <AVFoundation/AVAudioPlayer.h>
 -(void) beepWithSoundID:(UInt32)beepNumber {
  AudioServicesPlaySystemSound(beepNumber);
}
#End If

public Sub short_beep
    Dim NativeMe As NativeObject = Me
    NativeMe.RunMethod("beepWithSoundID:", Array(1323)) '1323=Train Sound
End Sub

Plays specified system sound, here is the list:
https://github.com/TUNER88/iOSSystemSoundsLibrary
 
Last edited:
Upvote 0
Top