本文整理匯總了Java中android.media.Ringtone.setStreamType方法的典型用法代碼示例。如果您正苦於以下問題:Java Ringtone.setStreamType方法的具體用法?Java Ringtone.setStreamType怎麽用?Java Ringtone.setStreamType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.Ringtone
的用法示例。
在下文中一共展示了Ringtone.setStreamType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onStopTrackingTouch
import android.media.Ringtone; //導入方法依賴的package包/類
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
final int stream = (Integer) seekBar.getTag();
am.setStreamVolume(stream, seekBar.getProgress(), 0);
if (stream == AudioManager.STREAM_RING) {
volume_modes.check(seekBar.getProgress() > 0 ?
(VolumeTracker.isVibrateOn(this, am) ? R.id.rd_vol_4 : R.id.rd_vol_3) :
R.id.rd_vol_1);
}
Ringtone tone = ringtoneMap.get(stream);
if (tone!=null && playMusic) {
tone.setStreamType(stream);
tone.play();
}
mLastControlledSeekbar = seekBar;
}
示例2: playNotificationSound
import android.media.Ringtone; //導入方法依賴的package包/類
private void playNotificationSound(Context ctxt)
{
final String soundPath = mPrefs.getString("pref_key_custom_ringtone", null);
if (soundPath != null && !soundPath.equals(""))
{
final Uri soundUri = Uri.parse(soundPath);
if (soundUri != null)
{
final Ringtone sfx = RingtoneManager.getRingtone(ctxt, soundUri);
if (sfx != null)
{
sfx.setStreamType(AudioManager.STREAM_NOTIFICATION);
sfx.play();
}
}
}
}
示例3: playSound
import android.media.Ringtone; //導入方法依賴的package包/類
private void playSound(int type) {
if (type < 0 || type > (mSounds.length-1) || mSounds[type] == null ||
!isPhoneIdle() || quietHoursActive()) return;
try {
final Ringtone sfx = RingtoneManager.getRingtone(mContext, mSounds[type]);
if (sfx != null) {
sfx.setStreamType(AudioManager.STREAM_NOTIFICATION);
sfx.play();
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
示例4: getRingtoneCompat
import android.media.Ringtone; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Ringtone getRingtoneCompat(Context context, Uri ringtoneUri) {
final Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
if (Const.SUPPORTS_LOLLIPOP) {
ringtone.setAudioAttributes(new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
.build());
} else {
ringtone.setStreamType(AudioManager.STREAM_NOTIFICATION);
}
return ringtone;
}