Audio options

What are the basic parameters for audio?

For example: sampling rate, buffer, baud rate

Anything api support api?

Thanks in advance!

+3


source to share


1 answer


There are four types of sound settings in android: 1) Alarm 2) Music 3) Ringtone 4) Notification First, create an AudioManager amanager object; If you want to install Volume use this code

For notification

AudioManager amanager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
amanager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);

      

For Alerm

amanager.setStreamVolume(AudioManager.STREAM_ALARM,AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);

      



For music

amanager.setStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);

      

For a ringtone

amanager.setStreamVolume(AudioManager.STREAM_RING,AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);

// Add new file to your media library
ContentValues values = new ContentValues(4);
long current = System.currentTimeMillis();
values.put(MediaStore.Audio.Media.TITLE, "audio" + audiofile.getName());
values.put(MediaStore.Audio.Media.DATE_ADDED, (int) (current / 1000));
values.put(MediaStore.Audio.Media.MIME_TYPE, "audio/3gpp");
values.put(MediaStore.Audio.Media.DATA, audiofile.getAbsolutePath());
ContentResolver contentResolver = getContentResolver();

Uri base = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Uri newUri = contentResolver.insert(base, values);

// Notifiy the media application on the device
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, newUri));

      

-2


source







All Articles