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.example.gangzhang.myapplication.VideoPlayerActivity.java
private void playVideo(Integer Media) { doCleanUp();//from ww w.ja v a 2s. c om String url = extras.get(VideoPlayerSettingFragment.KEY_URL).toString(); String username = extras.get(VideoPlayerSettingFragment.KEY_URERNAME).toString(); String password = extras.get(VideoPlayerSettingFragment.KEY_PASSWORD).toString(); Log.d(TAG, "url=" + url); Log.d(TAG, "username=" + username); Log.d(TAG, "pd=" + password); path = "rtsp://" + username + ":" + password + "@" + url; try { if (url.compareTo("") == 0) path = "/sdcard/download/hisi.asf"; // path = "/storage/sdcard/hisi.asf"; HashMap<String, String> options = new HashMap<String, String>(); options.put("rtsp_transport", "tcp"); // udp // options.put("user-agent", "userAgent"); // options.put("cookies", "cookies"); // options.put("analyzeduration", "1000000"); // Create a new media player and set the listeners mMediaPlayer = new MediaPlayer(this, hardEnabled); mMediaPlayer.setDataSource(this, Uri.parse(path), options); mMediaPlayer.setDisplay(holder); mMediaPlayer.prepare(); mMediaPlayer.setOnBufferingUpdateListener(this); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnVideoSizeChangedListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setBufferSize(1920 * 1080 * 5); setVolumeControlStream(AudioManager.STREAM_MUSIC); mProgressBar.setVisibility(View.VISIBLE); mProgressBar.startAnimation(operatingAnim); } catch (Exception e) { Log.e(TAG, "error: " + e.getMessage(), e); } }
From source file:github.popeen.dsub.activity.SubsonicActivity.java
@Override protected void onCreate(Bundle bundle) { sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE); if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) { // tv = true; }/* w ww . j a v a 2 s . c o m*/ PackageManager pm = getPackageManager(); if (!pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) { touchscreen = false; } setUncaughtExceptionHandler(); applyTheme(); applyFullscreen(); super.onCreate(bundle); startService(new Intent(this, DownloadService.class)); setVolumeControlStream(AudioManager.STREAM_MUSIC); if (getIntent().hasExtra(Constants.FRAGMENT_POSITION)) { lastSelectedPosition = getIntent().getIntExtra(Constants.FRAGMENT_POSITION, 0); } if (preferencesListener == null) { preferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { // When changing drawer settings change visibility switch (key) { case Constants.PREFERENCES_KEY_PODCASTS_ENABLED: setDrawerItemVisible(R.id.drawer_podcasts, false); break; case Constants.PREFERENCES_KEY_BOOKMARKS_ENABLED: setDrawerItemVisible(R.id.drawer_bookmarks, false); break; case Constants.PREFERENCES_KEY_INTERNET_RADIO_ENABLED: setDrawerItemVisible(R.id.drawer_internet_radio_stations, false); break; case Constants.PREFERENCES_KEY_SHARED_ENABLED: setDrawerItemVisible(R.id.drawer_shares, false); break; case Constants.PREFERENCES_KEY_CHAT_ENABLED: setDrawerItemVisible(R.id.drawer_chat, false); break; case Constants.PREFERENCES_KEY_ADMIN_ENABLED: setDrawerItemVisible(R.id.drawer_admin, false); break; } } }; Util.getPreferences(this).registerOnSharedPreferenceChangeListener(preferencesListener); } if (ContextCompat.checkSelfPermission(this, permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); } }
From source file:com.mobilis.android.nfc.activities.MagTekFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set up the window layout // if (mShowTitle) { // getActivity().requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // }// if(mShowTitle) // else { // getWindow().requestFeature(Window.FEATURE_NO_TITLE); // }/* w w w. java 2 s . c o m*/ // setContentView(R.layout.main); // // if (mShowTitle) // { // getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, // R.layout.custom_title); // }// if(mShowTitle) // // Set up the custom title // if (mShowTitle) // { // mTitleLeftTextView = (TextView) findViewById(R.id.title_left_text); // mTitleLeftTextView.setText(R.string.app_title); // mTitleLayout = (RelativeLayout) findViewById(R.id.relative_layout_title); // mTitleLayout.setVisibility(View.INVISIBLE); // }// if(mShowTitle) // // mAppStatusTextView = (TextView) findViewById(R.id.textview_app_status); // mInfoTextView = (TextView) findViewById(R.id.textview_info); // mCardDataEditText= (EditText) findViewById(R.id.edittext_carddata); // mGetConfigFromWeb=(CheckBox) findViewById(R.id.checkbox_getconfig); // mClearImageButton = (ImageButton) findViewById(R.id.imagebutton_clear); // mSubmitImageButton= (ImageButton) findViewById(R.id.imagebutton_submit); mMTSCRA = new MagTekSCRA(mSCRADataHandler); mAudioMgr = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE); // setStatus(R.string.status_default, Color.RED); InitializeData(); mIntCurrentVolume = mAudioMgr.getStreamVolume(AudioManager.STREAM_MUSIC); // mClearImageButton.setOnClickListener(new View.OnClickListener() { // public void onClick(View v) // { // clearAll(); // } // }); // // mSubmitImageButton.setOnClickListener(new View.OnClickListener() { // public void onClick(View v) // { // debugMsg("Android.Model=" + android.os.Build.MODEL); // debugMsg("Android.Device=" + android.os.Build.DEVICE); // debugMsg("Android.Product=" + android.os.Build.PRODUCT); // // String mStringBody=""; // try // { // String strVersion = ""; // PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); // strVersion = pInfo.versionName; // mStringBody = "App.Version=" + strVersion + "\nSDK.Version=" + mMTSCRA.getSDKVersion() + "\n"); // // } // catch(Exception ex) // { // // } // mStringBody += "Android.Model=" + android.os.Build.MODEL + "\n"); // mStringBody += "Android.Device=" + android.os.Build.DEVICE + "\n"); // mStringBody += "Android.Product=" + android.os.Build.PRODUCT + "\n"); // mStringBody += mStringDebugData; // mCardDataEditText.setText(mStringBody); // // /* // Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); // String[] recipients = new String[]{"softeng@magtek.com"}; // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "MagTek Audio Debug Info"); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, mStringBody); // emailIntent.setType("text/plain"); // startActivity(Intent.createChooser(emailIntent, "Send mail...")); // */ // } // }); Timer tTimer = new Timer(); TimerTask tTimerTask = new TimerTask() { public void run() { if (mMTSCRA.isDeviceConnected()) { if (mLongTimerInterval >= 2) { if (mMTSCRA.isDeviceConnected()) { if (mIntCurrentStatus == STATUS_IDLE) { // setStatus(R.string.status_default, Color.GREEN); } } // if(mDeviceStatus==BluetoothChatService.STATE_CONNECTED) else { // setStatus(R.string.status_default, Color.RED); } mLongTimerInterval = 0; } // if(mTimerInterval >= 2) } // if(mDeviceStatus==BluetoothChatService.STATE_CONNECTED) else { if ((mIntCurrentStatus == STATUS_IDLE) && (mIntCurrentDeviceStatus == MagTekSCRA.DEVICE_STATE_DISCONNECTED)) { // setStatus(R.string.status_default, Color.RED); } } mLongTimerInterval++; } }; tTimer.scheduleAtFixedRate(tTimerTask, 0, 1000); displayInfo(); }
From source file:com.kaltura.playersdk.PlayerViewController.java
private void setVolumeLevel(double percent) {//Itay AudioManager mgr = (AudioManager) mActivity.getSystemService(Context.AUDIO_SERVICE); if (percent > 0.01) { while (percent < 1.0) { percent *= 10;/*from w w w . j a v a 2 s.com*/ } } mgr.setStreamVolume(AudioManager.STREAM_MUSIC, (int) percent, 0); }
From source file:com.yohpapa.research.simplemusicplayer.PlaybackService.java
private MediaPlayer initializePlayer() { MediaPlayer player = new MediaPlayer(); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setOnPreparedListener(this); player.setOnCompletionListener(this); player.setOnErrorListener(this); player.setOnSeekCompleteListener(this); player.setWakeMode(this, PowerManager.PARTIAL_WAKE_LOCK); IntentFilter filter = new IntentFilter(); filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY); filter.addAction(Intent.ACTION_HEADSET_PLUG); filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); registerReceiver(audioOutputChangedEventReceiver, filter); return player; }
From source file:com.dena.app.usage.watcher.MainActivity.java
public boolean onKeyDown(int keyCode, KeyEvent evt) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI); return true; case KeyEvent.KEYCODE_VOLUME_DOWN: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI); return true; default://from w w w .j a va2 s. c o m break; } return super.onKeyDown(keyCode, evt); }
From source file:com.BibleQuote.BibleQuoteAndroid.ui.ReaderActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // For javascript debug /*final Thread.UncaughtExceptionHandler subclass = Thread.currentThread().getUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override/*from w w w.j av a 2 s. c om*/ public void uncaughtException(Thread paramThread, Throwable paramThrowable) { LogTxt.e(TAG, "uncaughtException", paramThrowable); subclass.uncaughtException(paramThread, paramThrowable); } });*/ BibleQuoteApp app = (BibleQuoteApp) getApplication(); boolean isServiceFinish = false; Bundle extras = getIntent().getExtras(); if (extras != null) { isServiceFinish = extras.getBoolean(ServiceActivity.SERVICE_FINISH, false); } // ?? ? , // ?? , if (app.isServiceRunning() && !isServiceFinish) { finish(); } else { setContentView(R.layout.reader); if (!DeviceInfo.isEInkSonyPRST()) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } setVolumeControlStream(AudioManager.STREAM_MUSIC); getSupportActionBar().setIcon(R.drawable.app_logo); getSupportActionBar().setDisplayShowTitleEnabled(false); ViewUtils.setActionBarBackground(this); myLibrarian = app.getCoreContext().getLibrarian(); mAsyncManager = app.getAsyncManager(); mAsyncManager.handleRetainedTask(mTask, this); initialyzeViews(); updateActivityMode(); BibleReference osisLink = new BibleReference(PreferenceHelper.restoreStateString("last_read")); if (!myLibrarian.isOSISLinkValid(osisLink)) { onChooseChapterClick(); } else { openChapterFromLink(osisLink); } } }
From source file:com.mylovemhz.simplay.MusicService.java
private void cueTrack() throws IOException, IndexOutOfBoundsException { Log.d(TAG_MUSIC_SERVICE, "Cue Track..."); AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); int result = audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); if (result != AudioManager.AUDIOFOCUS_GAIN) { return; //Failed to gain audio focus }/*from ww w .j av a 2s . c om*/ if (getCurrentState() == State.STOPPED) { mediaPlayer.reset(); currentState = State.IDLE; } if (getCurrentState() == State.IDLE) { if (trackQueue.size() == 0) { return; //nothing to play } if (hasPermission(Manifest.permission.WAKE_LOCK)) { if (!wifiLock.isHeld()) { wifiLock.acquire(); } Track track = trackQueue.get(currentTrackIndex); mediaPlayer.setDataSource(track.getUrl()); currentState = State.INITIALIZED; mediaPlayer.prepareAsync(); currentState = State.PREPARING; if (callbacks != null) callbacks.onLoading(); } else { Log.e(TAG_MUSIC_SERVICE, "need permission " + Manifest.permission.WAKE_LOCK); if (callbacks != null) { callbacks.onPermissionRequired(REQUEST_PERMISSION_WAKE_LOCK, Manifest.permission.WAKE_LOCK, RATIONALE_WAKE_LOCK); } } } }
From source file:com.juce.JuceAppActivity.java
@Override public void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); isScreenSaverEnabled = true;//w ww . j a va 2 s . c om hideActionBar(); viewHolder = new ViewHolder (this); setContentView (viewHolder); setVolumeControlStream (AudioManager.STREAM_MUSIC); permissionCallbackPtrMap = new HashMap<Integer, Long>(); }
From source file:com.greenkee.pokeADot.GameActivity.java
private void loadAudio() { audio = new SoundPool(7, AudioManager.STREAM_MUSIC, 0); bounceSound = audio.load(this, com.greenkee.pokeADot.R.raw.bounce, 1); collectSound = audio.load(this, com.greenkee.pokeADot.R.raw.collect, 1); deathSound = audio.load(this, com.greenkee.pokeADot.R.raw.death, 1); }