我有以下代码,但每次我只听到默认的 android 声音。
// create channel
NotificationChannel channel = new NotificationChannel(ANDROID_CHANNEL_ID,
ANDROID_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
// Sets whether notifications posted to this channel should display notification lights
channel.enableLights(true);
// Sets whether notification posted to this channel should vibrate.
channel.enableVibration(true);
// Sets the notification light color for notifications posted to this channel
channel.setLightColor(Color.GREEN);
// Sets whether notifications posted to this channel appear on the lockscreen or not
//channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
Uri uri = Uri.parse("android.resource://"+this.getPackageName()+"/" + R.raw.aperturaabductores);
AudioAttributes att = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
.build();
channel.setSound(uri,att);
这是我的声音pablomonteserin.es/aperturaabductores.wav http://pablomonteserin.es/aperturaabductores.wav
我试图看看你的声音文件和我的声音文件之间的区别。我使用 Audacity 软件。
你的声音文件的采样率为 22050Hz,而我使用的声音文件的采样率为 44100Hz。所以我将你的声音文件采样率转换为 44100Hz 并将其用作通知声音。现在可以了。
问题出在声音文件上。可能是 Android O 中的新变化,因为它在较旧的 Android 版本上运行良好。
This is how to resample-
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)