本文整理汇总了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;
}