I play a sound using:
public class NotificationFunction implements FREFunction {
public FREObject call(FREContext context, FREObject[] args) {
Context appContext = context.getActivity().getApplicationContext();
AudioManager mAudioManager = (AudioManager)
appContext.getSystemService(Context.AUDIO_SERVICE);
mAudioManager.loadSoundEffects();
mAudioManager.playSoundEffect(0);
It plays a default sound effect, how can I get it to play a custom sound effect.
Also I have tried to implement sound pool but it doesnt work, I implemented it the standard way but it doesnt work. Any ideas why? Or if I can use the audio manager for sounds instead?
Check with following code
using (AudioManager am= (AudioManager)WebViewActivity.Instance.GetSystemService(Context.AudioService))
{
int maxVol = am.GetStreamMaxVolume(Stream.Music);
float myVol= maxVol * volume;
am.SetStreamVolume(Stream.Music, (int)(myVol), 0);
using (SoundPool soundPool = new SoundPool(1, Stream.Music, 0))
{
int soundFileId = soundPool.Load(soundFilePath, 1);
soundPool.LoadComplete += (sender, eventArgs) =>
{
using (SoundPool soundPoolLoaded = sender as SoundPool)
{
soundPoolLoaded.Play(soundFileId, myVol,
myVol, 0, 0, 1.0f);
}
};
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.