private VLCMediaPlayer() { // Initialize and register Receiver if (mVLCMediaPlayerReceiver == null) { mVLCMediaPlayerReceiver = new VLCMediaPlayerReceiver(); IntentFilter intentFilter = new IntentFilter(PipeLine.PIPELINE_URLTRANSLATIONREPORTED); TomahawkApp.getContext().registerReceiver(mVLCMediaPlayerReceiver, intentFilter); } try { mLibVLC = LibVLC.getInstance(); mLibVLC.init(TomahawkApp.getContext()); mLibVLC.setHardwareAcceleration(LibVLC.HW_ACCELERATION_DISABLED); } catch (LibVlcException e) { Log.e(TAG, "<init>: Failed to initialize LibVLC: " + e.getLocalizedMessage()); } }
private void fillViews() { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()); float[] bands = null; String[] presets = null; try { libVlc = VLCInstance.getLibVlcInstance(); bands = libVlc.getBands(); presets = libVlc.getPresets(); if (equalizer == null) equalizer = Preferences.getFloatArray(preferences, "equalizer_values"); if (equalizer == null) equalizer = new float[bands.length + 1]; } catch (LibVlcException e) { e.printStackTrace(); return; } // on/off button.setChecked(libVlc.getEqualizer() != null); button.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (libVlc == null) return; libVlc.setEqualizer(isChecked ? equalizer : null); } }); // presets equalizer_presets.setAdapter( new ArrayAdapter<String>( getActivity(), android.R.layout.simple_spinner_dropdown_item, presets)); // Set the default selection asynchronously to prevent a layout initialization bug. final int equalizer_preset_pref = preferences.getInt("equalizer_preset", 0); equalizer_presets.post( new Runnable() { @Override public void run() { equalizer_presets.setSelection(equalizer_preset_pref, false); equalizer_presets.setOnItemSelectedListener(mPresetListener); } }); // preamp preamp.setMax(40); preamp.setProgress((int) equalizer[0] + 20); preamp.setOnSeekBarChangeListener(mPreampListener); // bands for (int i = 0; i < bands.length; i++) { float band = bands[i]; EqualizerBar bar = new EqualizerBar(getActivity(), band); bar.setValue(equalizer[i + 1]); bar.setListener(new BandListener(i + 1)); bands_layout.addView(bar); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1); bar.setLayoutParams(params); } }