List of usage examples for android.media AudioManager STREAM_MUSIC
int STREAM_MUSIC
To view the source code for android.media AudioManager STREAM_MUSIC.
Click Source Link
From source file:com.gao.im.ui.CCPActivityBase.java
public void init(Context context, FragmentActivity activity) { mActionBarActivity = activity;/* ww w . j a v a 2 s . c om*/ onInit(); mAudioManager = AudioManagerTools.getInstance().getAudioManager(); mMusicMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); int layoutId = getLayoutId(); mLayoutInflater = LayoutInflater.from(mActionBarActivity); mBaseLayoutView = mLayoutInflater.inflate(R.layout.ccp_activity, null); mTransLayerView = mBaseLayoutView.findViewById(R.id.ccp_trans_layer); LinearLayout mRootView = (LinearLayout) mBaseLayoutView.findViewById(R.id.ccp_root_view); mContentFrameLayout = (FrameLayout) mBaseLayoutView.findViewById(R.id.ccp_content_fl); if (getTitleLayout() != -1) { mTopBarView = mLayoutInflater.inflate(getTitleLayout(), null); mRootView.addView(mTopBarView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); } if (layoutId != -1) { mContentView = getContentLayoutView(); if (mContentView == null) { mContentView = mLayoutInflater.inflate(getLayoutId(), null); } mRootView.addView(mContentView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); } onBaseContentViewAttach(mBaseLayoutView); CCPLayoutListenerView listenerView = (CCPLayoutListenerView) mActionBarActivity .findViewById(R.id.ccp_content_fl); if (listenerView != null && mActionBarActivity.getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) { listenerView.setOnSizeChangedListener(new CCPLayoutListenerView.OnCCPViewSizeChangedListener() { @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { LogUtil.d(LogUtil.getLogUtilsTag(getClass()), "oldh - h = " + (oldh - h)); } }); } CCPAppManager.setContext(mActionBarActivity); }
From source file:net.hyx.app.volumenotification.NotificationFactory.java
void setVolume(int position) { int selection = settings.getButtonSelection(position); int direction = AudioManager.ADJUST_SAME; int type = STREAM_TYPES[selection]; if (type == AudioManager.STREAM_MUSIC && settings.getToggleMute()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { direction = AudioManager.ADJUST_TOGGLE_MUTE; } else {//from w ww. ja v a 2 s . co m _mute = !_mute; audio.setStreamMute(type, _mute); } } else if (type == AudioManager.STREAM_RING && settings.getToggleSilent()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { direction = AudioManager.ADJUST_TOGGLE_MUTE; } else { _silent = !_silent; audio.setStreamMute(type, _silent); } } audio.adjustStreamVolume(type, direction, AudioManager.FLAG_SHOW_UI); }
From source file:com.racoon.ampdroid.Mp3PlayerService.java
@Override public void onCreate() { mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setOnCompletionListener(new SongComplitionListener()); pause = false;//from ww w .j a v a 2s .co m session = ""; }
From source file:ca.rmen.android.palidamuerte.app.poem.detail.PoemDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_poem_detail); getActionBar().setDisplayShowCustomEnabled(true); getActionBar().setCustomView(R.layout.poem_number); setVolumeControlStream(AudioManager.STREAM_MUSIC); mTextViewPageNumber = (TextView) getActionBar().getCustomView(); ActionBar.setCustomFont(this); mViewPager = (ViewPager) findViewById(R.id.pager); // If this is the first time we open the activity, we will use the poem id provided in the intent. // If we are recreating the activity (because of a device rotation, for example), we will display the poem that the user // had previously swiped to, using the ViewPager. final long poemId; if (savedInstanceState != null) poemId = savedInstanceState.getLong(PoemDetailFragment.ARG_ITEM_ID); else/* ww w. ja va2 s.co m*/ poemId = getIntent().getLongExtra(PoemDetailFragment.ARG_ITEM_ID, -1); new AsyncTask<Void, Void, PoemPagerAdapter>() { private String mActivityTitle; @Override protected PoemPagerAdapter doInBackground(Void... params) { mActivityTitle = Poems.getActivityTitle(PoemDetailActivity.this, getIntent()); PoemSelection poemSelection = Poems.getPoemSelection(PoemDetailActivity.this, getIntent()); return new PoemPagerAdapter(PoemDetailActivity.this, poemSelection, getSupportFragmentManager()); } @Override protected void onPostExecute(PoemPagerAdapter result) { if (isFinishing()) return; try { mPoemPagerAdapter = result; mViewPager.setAdapter(mPoemPagerAdapter); mViewPager.setOnPageChangeListener(mOnPageChangeListener); findViewById(R.id.activity_loading).setVisibility(View.GONE); int position = mPoemPagerAdapter.getPositionForPoem(poemId); mViewPager.setCurrentItem(position); getActionBar().setTitle(mActivityTitle); String pageNumber = getString(R.string.page_number, position + 1, mPoemPagerAdapter.getCount()); mTextViewPageNumber.setText(pageNumber); invalidateOptionsMenu(); } catch (IllegalStateException e) { // Don't have time to investigate the root cause now //https://groups.google.com/forum/#!topic/android-developers/Zpb8YSzTltA Log.e(TAG, e.getMessage(), e); } } }.execute(); // Show the Up button in the action bar. getActionBar().setDisplayHomeAsUpEnabled(true); }
From source file:com.devalladolid.musictoday.activities.BaseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mToken = MusicPlayer.bindToService(this, this); mPlaybackStatus = new PlaybackStatus(this); //make volume keys change multimedia volume even if music is not playing now setVolumeControlStream(AudioManager.STREAM_MUSIC); }
From source file:com.andrew.apolloMod.activities.QueryBrowserActivity.java
/** Called when the activity is first created. */ @SuppressWarnings("deprecation") @Override/*from w w w . j av a 2 s . c o m*/ public void onCreate(Bundle icicle) { super.onCreate(icicle); setVolumeControlStream(AudioManager.STREAM_MUSIC); mAdapter = (QueryListAdapter) getLastNonConfigurationInstance(); mToken = MusicUtils.bindToService(this, this); // defer the real work until we're bound to the service }
From source file:fi.mikuz.boarder.gui.internet.Register.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.internet_register); this.setVolumeControlStream(AudioManager.STREAM_MUSIC); mSubmit = (Button) findViewById(R.id.submit); mUserName = (EditText) findViewById(R.id.userName); mUserPassword = (EditText) findViewById(R.id.userPassword); mUserPassword2 = (EditText) findViewById(R.id.userPassword2); mUserEmail = (EditText) findViewById(R.id.userEmail); mSubmit.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (!mUserPassword.getText().toString().equals(mUserPassword2.getText().toString())) { Toast.makeText(Register.this, "The passwords don't match", Toast.LENGTH_LONG).show(); } else if (mUserPassword.length() < 6) { Toast.makeText(Register.this, "Password length must be at least 6 characters", Toast.LENGTH_LONG).show(); } else { try { mWaitDialog = new TimeoutProgressDialog(Register.this, "Waiting for response", TAG, false); HashMap<String, String> sendList = new HashMap<String, String>(); sendList.put(InternetMenu.USERNAME_KEY, mUserName.getText().toString()); sendList.put(InternetMenu.PASSWORD_KEY, Security.passwordHash(mUserPassword.getText().toString())); sendList.put(InternetMenu.EMAIL_KEY, mUserEmail.getText().toString()); new ConnectionManager(Register.this, InternetMenu.mRegistrationURL, sendList); } catch (NoSuchAlgorithmException e) { mWaitDialog.dismiss(); String msg = "Couldn't hash the password"; Toast.makeText(Register.this, msg, Toast.LENGTH_LONG).show(); Log.e(TAG, msg, e);//from ww w . ja v a 2 s . c o m } } } }); }
From source file:com.shinymayhem.radiopresets.FragmentPlayer.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (LOCAL_LOGV) log("onCreateView()", "v"); //inflate view from layout View view = inflater.inflate(R.layout.player_fragment, container, false); AudioManager audio = (AudioManager) this.getActivity().getSystemService(Context.AUDIO_SERVICE); SeekBar volumeSlider = (SeekBar) view.findViewById(R.id.volume_slider); //slider max = volume stream max volumeSlider.setMax(audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC)); //detect slider updates volumeSlider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { //update volume as slider is moved @Override//from w w w. j a va2 s .c o m public void onProgressChanged(SeekBar slider, int progress, boolean fromUser) { if (LOCAL_LOGV) log("onProgressChanged(): " + String.valueOf(progress), "v"); if (fromUser) //responding to touch slide event { mListener.setVolume(progress); } else //progress probably changed as a result of volume changing { } } @Override public void onStartTrackingTouch(SeekBar slider) { } @Override public void onStopTrackingTouch(SeekBar slider) { } }); return view; }
From source file:at.kropf.curriculumvitae.augmented.AbstractArchitectCamActivity.java
/** Called when the activity is first created. */ @SuppressLint("NewApi") @Override//from w w w.ja v a2s . c o m public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* pressing volume up/down should cause music volume changes */ this.setVolumeControlStream(AudioManager.STREAM_MUSIC); /* set samples content view */ this.setContentView(this.getContentViewId()); this.setTitle(this.getActivityTitle()); /* * this enables remote debugging of a WebView on Android 4.4+ when debugging = true in AndroidManifest.xml * If you get a compile time error here, ensure to have SDK 19+ used in your ADT/Eclipse. * You may even delete this block in case you don't need remote debugging or don't have an Android 4.4+ device in place. * Details: https://developers.google.com/chrome-developer-tools/docs/remote-debugging */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) { WebView.setWebContentsDebuggingEnabled(true); } } /* set AR-view for life-cycle notifications etc. */ this.architectView = (ArchitectView) this.findViewById(this.getArchitectViewId()); /* pass SDK key if you have one, this one is only valid for this package identifier and must not be used somewhere else */ final StartupConfiguration config = new StartupConfiguration(this.getWikitudeSDKLicenseKey(), this.getFeatures(), this.getCameraPosition()); try { /* first mandatory life-cycle notification */ this.architectView.onCreate(config); } catch (RuntimeException rex) { this.architectView = null; Toast.makeText(getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT).show(); Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex); } // set accuracy listener if implemented, you may e.g. show calibration prompt for compass using this listener this.sensorAccuracyListener = this.getSensorAccuracyListener(); // set urlListener, any calls made in JS like "document.location = 'architectsdk://foo?bar=123'" is forwarded to this listener, use this to interact between JS and native Android activity/fragment this.urlListener = this.getUrlListener(); // register valid urlListener in architectView, ensure this is set before content is loaded to not miss any event if (this.urlListener != null && this.architectView != null) { this.architectView.registerUrlListener(this.getUrlListener()); } if (hasGeo()) { // listener passed over to locationProvider, any location update is handled here this.locationListener = new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } @Override public void onLocationChanged(final Location location) { // forward location updates fired by LocationProvider to architectView, you can set lat/lon from any location-strategy if (location != null) { // sore last location as member, in case it is needed somewhere (in e.g. your adjusted project) AbstractArchitectCamActivity.this.lastKnownLocaton = location; if (AbstractArchitectCamActivity.this.architectView != null) { // check if location has altitude at certain accuracy level & call right architect method (the one with altitude information) if (location.hasAltitude() && location.hasAccuracy() && location.getAccuracy() < 7) { AbstractArchitectCamActivity.this.architectView.setLocation(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy()); } else { AbstractArchitectCamActivity.this.architectView.setLocation(location.getLatitude(), location.getLongitude(), location.hasAccuracy() ? location.getAccuracy() : 1000); } } } } }; // locationProvider used to fetch user position this.locationProvider = getLocationProvider(this.locationListener); } else { this.locationProvider = null; this.locationListener = null; } }
From source file:com.lamcreations.scaffold.common.activities.VideoSplashScreenActivity.java
@Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { Surface s = new Surface(surface); try {//w ww .j a va 2s . c o m mMediaPlayer = MediaPlayer.create(this, getVideoRawResId()); mMediaPlayer.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT); mMediaPlayer.setSurface(s); mMediaPlayer.setOnBufferingUpdateListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnVideoSizeChangedListener(this); mMediaPlayer.setOnSeekCompleteListener(this); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mTextureView.setAspectRatio(mMediaPlayer.getVideoWidth(), mMediaPlayer.getVideoHeight()); } catch (IllegalArgumentException | SecurityException | IllegalStateException e) { Log.d(TAG, e.getMessage()); } }