Search in sources :

Example 26 with Ringtone

use of android.media.Ringtone in project HoloEverywhere by Prototik.

the class _RingtonePickerDialog method run.

@Override
public void run() {
    if (sampleRingtonePos == silentPos) {
        ringtoneManager.stopPreviousRingtone();
        return;
    }
    if (defaultRingtone != null && defaultRingtone.isPlaying()) {
        defaultRingtone.stop();
        defaultRingtone = null;
    }
    Ringtone ringtone;
    if (sampleRingtonePos == defaultRingtonePos) {
        if (defaultRingtone == null) {
            defaultRingtone = RingtoneManager.getRingtone(context, uriForDefaultItem);
        }
        ringtone = defaultRingtone;
        ringtoneManager.stopPreviousRingtone();
    } else {
        ringtone = ringtoneManager.getRingtone(getRingtoneManagerPosition(sampleRingtonePos));
    }
    if (ringtone != null) {
        ringtone.play();
    }
}
Also used : Ringtone(android.media.Ringtone)

Example 27 with Ringtone

use of android.media.Ringtone in project android_frameworks_base by crdroidandroid.

the class Notifier method playWirelessChargingStartedSound.

private void playWirelessChargingStartedSound() {
    final boolean enabled = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.CHARGING_SOUNDS_ENABLED, 1) != 0;
    final String soundPath = Settings.Global.getString(mContext.getContentResolver(), Settings.Global.WIRELESS_CHARGING_STARTED_SOUND);
    if (enabled && soundPath != null) {
        final Uri soundUri = Uri.parse("file://" + soundPath);
        if (soundUri != null) {
            final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
            if (sfx != null) {
                sfx.setStreamType(AudioManager.STREAM_SYSTEM);
                sfx.play();
            }
        }
    }
    mSuspendBlocker.release();
}
Also used : Ringtone(android.media.Ringtone) Uri(android.net.Uri)

Aggregations

Ringtone (android.media.Ringtone)27 Uri (android.net.Uri)18 ContentResolver (android.content.ContentResolver)8 Intent (android.content.Intent)6 AudioManager (android.media.AudioManager)4 Handler (android.os.Handler)1 Vibrator (android.os.Vibrator)1 CallNotificationBuilder (org.thoughtcrime.securesms.webrtc.CallNotificationBuilder)1