use of org.videolan.vlc.gui.view.EqualizerBar in project vlc-android by videolan.
the class EqualizerFragment method updateEqualizer.
private void updateEqualizer(int pos) {
if (updateAlreadyHandled) {
updateAlreadyHandled = false;
} else {
if (getEqualizerType(pos) == TYPE_PRESET) {
mEqualizer = MediaPlayer.Equalizer.createFromPreset(pos);
mState.update(pos, true);
} else if (getEqualizerType(pos) == TYPE_CUSTOM) {
mEqualizer = VLCOptions.getCustomSet(context, allSets.get(pos));
mState.update(pos, true);
} else if (getEqualizerType(pos) == TYPE_NEW) {
mEqualizer = MediaPlayer.Equalizer.create();
mState.update(pos, false);
}
}
binding.equalizerPreamp.setProgress((int) mEqualizer.getPreAmp() + 20);
for (int i = 0; i < BAND_COUNT; ++i) {
EqualizerBar bar = (EqualizerBar) binding.equalizerBands.getChildAt(i);
if (bar != null)
bar.setValue(mEqualizer.getAmp(i));
}
if (binding.equalizerButton.isChecked())
mService.setEqualizer(mEqualizer);
}
use of org.videolan.vlc.gui.view.EqualizerBar in project vlc-android by videolan.
the class EqualizerFragment method fillViews.
private void fillViews() {
context = getActivity();
if (context == null)
return;
allSets.clear();
allSets = new ArrayList<>();
allSets.addAll(Arrays.asList(getEqualizerPresets()));
presetCount = allSets.size();
for (Map.Entry<String, ?> entry : PreferenceManager.getDefaultSharedPreferences(context).getAll().entrySet()) {
if (entry.getKey().startsWith("custom_equalizer_")) {
allSets.add(entry.getKey().replace("custom_equalizer_", "").replace("_", " "));
customCount++;
}
}
allSets.add(newPresetName);
mEqualizer = VLCOptions.getEqualizerSetFromSettings(context, true);
// on/off
binding.equalizerButton.setChecked(VLCOptions.getEqualizerEnabledState(context));
binding.equalizerButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (mService != null)
if (isChecked)
mService.setEqualizer(mEqualizer);
else
mService.setEqualizer(null);
}
});
binding.equalizerSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
createSaveCustomSetDialog(binding.equalizerPresets.getSelectedItemPosition(), true, false);
}
});
binding.equalizerDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
createDeleteCustomSetSnacker();
}
});
binding.equalizerRevert.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
revertCustomSetChanges();
}
});
// presets
adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item, allSets);
binding.equalizerPresets.setAdapter(adapter);
// Set the default selection asynchronously to prevent a layout initialization bug.
binding.equalizerPresets.post(new Runnable() {
@Override
public void run() {
binding.equalizerPresets.setOnItemSelectedListener(mSetListener);
final int pos = allSets.indexOf(VLCOptions.getEqualizerNameFromSettings(context));
mState.update(pos, VLCOptions.getEqualizerSavedState(context));
updateAlreadyHandled = true;
if (binding.equalizerButton.isChecked() || !mState.saved) {
savePos = pos;
revertPos = getEqualizerType(pos) == TYPE_CUSTOM ? pos : 0;
binding.equalizerPresets.setSelection(pos);
} else {
updateEqualizer(0);
}
}
});
// preamp
binding.equalizerPreamp.setMax(40);
binding.equalizerPreamp.setProgress((int) mEqualizer.getPreAmp() + 20);
binding.equalizerPreamp.setOnSeekBarChangeListener(mPreampListener);
// bands
for (int i = 0; i < BAND_COUNT; i++) {
float band = MediaPlayer.Equalizer.getBandFrequency(i);
EqualizerBar bar = new EqualizerBar(context, band);
bar.setValue(mEqualizer.getAmp(i));
bar.setListener(new BandListener(i));
binding.equalizerBands.addView(bar);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1);
bar.setLayoutParams(params);
}
}
use of org.videolan.vlc.gui.view.EqualizerBar in project vlc-android by GeoffreyMetais.
the class EqualizerFragment method fillViews.
private void fillViews() {
context = getActivity();
if (context == null)
return;
allSets.clear();
allSets = new ArrayList<>();
allSets.addAll(Arrays.asList(getEqualizerPresets()));
presetCount = allSets.size();
for (Map.Entry<String, ?> entry : PreferenceManager.getDefaultSharedPreferences(context).getAll().entrySet()) {
if (entry.getKey().startsWith("custom_equalizer_")) {
allSets.add(entry.getKey().replace("custom_equalizer_", "").replace("_", " "));
customCount++;
}
}
allSets.add(newPresetName);
mEqualizer = VLCOptions.getEqualizerSetFromSettings(context, true);
// on/off
binding.equalizerButton.setChecked(VLCOptions.getEqualizerEnabledState(context));
binding.equalizerButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (mService != null)
if (isChecked)
mService.setEqualizer(mEqualizer);
else
mService.setEqualizer(null);
}
});
binding.equalizerSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
createSaveCustomSetDialog(binding.equalizerPresets.getSelectedItemPosition(), true, false);
}
});
binding.equalizerDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
createDeleteCustomSetSnacker();
}
});
binding.equalizerRevert.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
revertCustomSetChanges();
}
});
// presets
adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item, allSets);
binding.equalizerPresets.setAdapter(adapter);
// Set the default selection asynchronously to prevent a layout initialization bug.
binding.equalizerPresets.post(new Runnable() {
@Override
public void run() {
binding.equalizerPresets.setOnItemSelectedListener(mSetListener);
final int pos = allSets.indexOf(VLCOptions.getEqualizerNameFromSettings(context));
mState.update(pos, VLCOptions.getEqualizerSavedState(context));
updateAlreadyHandled = true;
if (binding.equalizerButton.isChecked() || !mState.saved) {
savePos = pos;
revertPos = getEqualizerType(pos) == TYPE_CUSTOM ? pos : 0;
binding.equalizerPresets.setSelection(pos);
} else {
updateEqualizer(0);
}
}
});
// preamp
binding.equalizerPreamp.setMax(40);
binding.equalizerPreamp.setProgress((int) mEqualizer.getPreAmp() + 20);
binding.equalizerPreamp.setOnSeekBarChangeListener(mPreampListener);
// bands
for (int i = 0; i < BAND_COUNT; i++) {
float band = MediaPlayer.Equalizer.getBandFrequency(i);
EqualizerBar bar = new EqualizerBar(context, band);
bar.setValue(mEqualizer.getAmp(i));
bar.setListener(new BandListener(i));
binding.equalizerBands.addView(bar);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1);
bar.setLayoutParams(params);
}
}
use of org.videolan.vlc.gui.view.EqualizerBar in project vlc-android by GeoffreyMetais.
the class EqualizerFragment method updateEqualizer.
private void updateEqualizer(int pos) {
if (updateAlreadyHandled) {
updateAlreadyHandled = false;
} else {
if (getEqualizerType(pos) == TYPE_PRESET) {
mEqualizer = MediaPlayer.Equalizer.createFromPreset(pos);
mState.update(pos, true);
} else if (getEqualizerType(pos) == TYPE_CUSTOM) {
mEqualizer = VLCOptions.getCustomSet(context, allSets.get(pos));
mState.update(pos, true);
} else if (getEqualizerType(pos) == TYPE_NEW) {
mEqualizer = MediaPlayer.Equalizer.create();
mState.update(pos, false);
}
}
binding.equalizerPreamp.setProgress((int) mEqualizer.getPreAmp() + 20);
for (int i = 0; i < BAND_COUNT; ++i) {
EqualizerBar bar = (EqualizerBar) binding.equalizerBands.getChildAt(i);
if (bar != null)
bar.setValue(mEqualizer.getAmp(i));
}
if (binding.equalizerButton.isChecked())
mService.setEqualizer(mEqualizer);
}
Aggregations