本文整理汇总了Java中android.media.audiofx.LoudnessEnhancer类的典型用法代码示例。如果您正苦于以下问题:Java LoudnessEnhancer类的具体用法?Java LoudnessEnhancer怎么用?Java LoudnessEnhancer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoudnessEnhancer类属于android.media.audiofx包,在下文中一共展示了LoudnessEnhancer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LoudnessEnhancerController
import android.media.audiofx.LoudnessEnhancer; //导入依赖的package包/类
public LoudnessEnhancerController(Context context, int audioSessionId) {
this.context = context;
try {
this.audioSessionId = audioSessionId;
enhancer = new LoudnessEnhancer(audioSessionId);
} catch (Throwable x) {
Log.w(TAG, "Failed to create enhancer", x);
}
}
示例2: create
import android.media.audiofx.LoudnessEnhancer; //导入依赖的package包/类
@Override
public AudioEffect create(int audioSession) {
try {
return new LoudnessEnhancer(audioSession);
} catch (RuntimeException e) {
// NOTE: some devices doesn't support LoudnessEnhancer class and may throw an exception
// (ME176C throws IllegalArgumentException)
Log.w(TAG, "Failed to instantiate loudness enhancer class", e);
}
return null;
}
示例3: initLoudnessEnhancer
import android.media.audiofx.LoudnessEnhancer; //导入依赖的package包/类
public static void initLoudnessEnhancer(int audioID) {
EndLoudnessEnhancer();
try {
loudnessEnhancer = new LoudnessEnhancer(audioID);
int loud = Extras.getInstance().saveEq().getInt(LOUD_BOOST, 0);
if (loud > 0) {
setLoudnessEnhancerGain(loud);
}else {
setLoudnessEnhancerGain(0);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: getTargetGain
import android.media.audiofx.LoudnessEnhancer; //导入依赖的package包/类
@Override
public float getTargetGain(AudioEffect effect) {
return ((LoudnessEnhancer) effect).getTargetGain();
}
示例5: setTargetGain
import android.media.audiofx.LoudnessEnhancer; //导入依赖的package包/类
@Override
public void setTargetGain(AudioEffect effect, int gainmB) {
((LoudnessEnhancer) effect).setTargetGain(gainmB);
}
示例6: musicHandler
import android.media.audiofx.LoudnessEnhancer; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
public musicHandler(musicPlayer Gh) {
mEvent = new Event("PLayer");
this.Gh = Gh;
loadStartup();
mediaplayer = new MediaPlayer();
mediaplayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
if(needPlay){
isPrepared = true;
play(needId);
}else{
isPrepared = true;
if(needStop){
needStop = false;
}else{
mediaplayer.start();
}
mediaplayer.setOnCompletionListener(OC);
mEvent.trigger(playerEvents.SONG_CHANGED);
}
}
});
needStop = true;
playByNumber(0);
EQs = new EqlizerSettings(Gh.getBaseContext());
bass = new BassBoost(0, mediaplayer.getAudioSessionId());
bass.setEnabled(true);
equlizer = new Equalizer(0, mediaplayer.getAudioSessionId());
equlizer.setEnabled(true);
virtualizer = new Virtualizer(0, mediaplayer.getAudioSessionId());
virtualizer.setEnabled(true);
if(android.os.Build.VERSION.SDK_INT >= 19){
loudness = new LoudnessEnhancer( mediaplayer.getAudioSessionId());
loudness.setEnabled(true);
}else{
loudness = null;
}
setEQs(EQs.isOn);
setBass(EQs.BASS);
setTrable(EQs.TRABLE);
setVoice(EQs.VOICE);
setVirtualizer(EQs.VIRCHULIZER);
setLoudnessEnhancer(EQs.LOUDNESS);
mEvent.trigger(playerEvents.EQ_CHANGED);
mEvent.trigger(playerEvents.PLAYER_COMPLETE);
}
示例7: onCreate
import android.media.audiofx.LoudnessEnhancer; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onCreate() {
t0 = System.currentTimeMillis();
SpeakerBoost.log("Creating service at "+t0);
options = PreferenceManager.getDefaultSharedPreferences(this);
settings = new Settings(this, true);
settings.load(options);
if (!settings.haveEqualizer()) {
settings.boostValue = 0;
settings.save(options);
if (19 <= Build.VERSION.SDK_INT) {
Boolean have = false;
for (AudioEffect.Descriptor d : AudioEffect.queryEffects()) {
if (d.uuid.equals(LoudnessEnhancer.EFFECT_TYPE_LOUDNESS_ENHANCER)) {
have = true;
break;
}
}
if (!have) {
Toast.makeText(this, "Your device doesn't support the LoudnessEnhancer effect that SpeakerBoost needs.", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(this, "Error: Try later or reboot", Toast.LENGTH_LONG).show();
}
}
else {
Toast.makeText(this, "Error: Try later or reboot", Toast.LENGTH_LONG).show();
}
SpeakerBoost.log("Error setting up equalizer");
}
else {
// Toast.makeText(this, "Equalizer activated", 5000).show();
SpeakerBoost.log("Success setting up equalizer");
}
if (Options.getNotify(options) != Options.NOTIFY_NEVER) {
Notification n = new Notification(
R.drawable.equalizeron,
"SpeakerBoost",
System.currentTimeMillis());
Intent i = new Intent(this, SpeakerBoost.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
n.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
n.setLatestEventInfo(this, "SpeakerBoost",
settings.describe(),
PendingIntent.getActivity(this, 0, i, 0));
SpeakerBoost.log("notify from service "+n.toString());
startForeground(SpeakerBoost.NOTIFICATION_ID, n);
}
else {
}
if (settings.isEqualizerActive())
settings.setEqualizer();
else
settings.disableEqualizer();
// if (settings.override) {
// Runnable logRunnable = new Runnable(){
// @Override
// public void run() {
// interruptReader = false;
// monitorLog();
// }};
// logThread = new Thread(logRunnable);
//
// logThread.start();
// }
}