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.tt.engtrain.showcontent.ContentListItemActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_baselist); mSpeechEvaluator = SpeechEvaluator.createEvaluator(ContentListItemActivity.this, null); mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT); int iMinBufSize = AudioTrack.getMinBufferSize(8000, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT); audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 8000, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT, iMinBufSize, AudioTrack.MODE_STREAM); mTts = SpeechSynthesizer.createSynthesizer(this, mTtsInitListener); initData();/* w w w . j a v a 2s . co m*/ initListView(); // initspker(); }
From source file:github.popeen.dsub.util.compat.RemoteControlClientLP.java
@Override public void register(Context context, ComponentName mediaButtonReceiverComponent) { downloadService = (DownloadService) context; mediaSession = new MediaSessionCompat(downloadService, "DSub MediaSession"); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(mediaButtonReceiverComponent); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, mediaButtonIntent, 0);/*from w w w . jav a2s . c om*/ mediaSession.setMediaButtonReceiver(mediaPendingIntent); Intent activityIntent = new Intent(context, SubsonicFragmentActivity.class); activityIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD, true); activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent activityPendingIntent = PendingIntent.getActivity(context, 0, activityIntent, 0); mediaSession.setSessionActivity(activityPendingIntent); mediaSession.setFlags( MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS | MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS); mediaSession.setCallback(new EventCallback()); mediaSession.setPlaybackToLocal(AudioManager.STREAM_MUSIC); mediaSession.setActive(true); Bundle sessionExtras = new Bundle(); sessionExtras.putBoolean(WEAR_BACKGROUND_THEME, true); sessionExtras.putBoolean(WEAR_RESERVE_SKIP_TO_PREVIOUS, true); sessionExtras.putBoolean(WEAR_RESERVE_SKIP_TO_NEXT, true); sessionExtras.putBoolean(AUTO_RESERVE_SKIP_TO_PREVIOUS, true); sessionExtras.putBoolean(AUTO_RESERVE_SKIP_TO_NEXT, true); mediaSession.setExtras(sessionExtras); imageLoader = SubsonicActivity.getStaticImageLoader(context); }
From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java
@SuppressLint("NewApi") @Override/* w w w .j a va2 s. co m*/ protected void onCreate(Bundle savedInstanceState) { mContext = getApplicationContext(); mApp = (Common) getApplicationContext(); mApp.setNowPlayingActivity(this); setNowPlayingActivityListener(mApp.getPlaybackKickstarter()); mFadeInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.slide_in_from_top); mFadeInAnimation.setDuration(700); super.onCreate(savedInstanceState); setContentView(R.layout.activity_now_playing); //Set the volume stream for this activity. this.setVolumeControlStream(AudioManager.STREAM_MUSIC); //ViewPager. mViewPager = (ViewPager) findViewById(R.id.nowPlayingPlaylistPager); //Seekbar indicator. mSeekbarIndicatorLayoutParent = (RelativeLayout) findViewById(R.id.seekbarIndicatorParent); mSeekbarIndicatorLayout = (RelativeLayout) findViewById(R.id.seekbarIndicator); mSeekbarIndicatorText = (TextView) findViewById(R.id.seekbarIndicatorText); mSeekbarIndicatorLayoutParent.setVisibility(View.GONE); //Playback Controls. mControlsLayoutHeaderParent = (RelativeLayout) findViewById(R.id.now_playing_controls_header_parent); mControlsLayoutHeader = (RelativeLayout) findViewById(R.id.now_playing_controls_header); mPlayPauseButtonBackground = (RelativeLayout) findViewById(R.id.playPauseButtonBackground); mPlayPauseButton = (ImageButton) findViewById(R.id.playPauseButton); mNextButton = (ImageButton) findViewById(R.id.nextButton); mPreviousButton = (ImageButton) findViewById(R.id.previousButton); mShuffleButton = (ImageButton) findViewById(R.id.shuffleButton); mRepeatButton = (ImageButton) findViewById(R.id.repeatButton); //Song info/seekbar elements. mSeekbar = (SeekBar) findViewById(R.id.nowPlayingSeekBar); mStreamingProgressBar = (ProgressBar) findViewById(R.id.startingStreamProgressBar); mStreamingProgressBar.setVisibility(View.GONE); try { mSeekbar.setThumb(getResources().getDrawable(R.drawable.transparent_drawable)); } catch (Exception e) { e.printStackTrace(); } if (mApp.getCurrentTheme() == Common.DARK_THEME) { mNextButton.setAlpha(1f); mPreviousButton.setAlpha(1f); } //KitKat specific layout code. setKitKatTranslucentBars(); //Set the control buttons and background. //setControlButtonsBackground(); setPlayPauseButton(); setShuffleButtonIcon(); setRepeatButtonIcon(); //Set the click listeners. mSeekbar.setOnSeekBarChangeListener(seekBarChangeListener); mNextButton.setOnClickListener(mOnClickNextListener); mPreviousButton.setOnClickListener(mOnClickPreviousListener); mPlayPauseButton.setOnClickListener(playPauseClickListener); mPlayPauseButtonBackground.setOnClickListener(playPauseClickListener); mShuffleButton.setOnClickListener(shuffleButtonClickListener); mRepeatButton.setOnClickListener(repeatButtonClickListener); //Apply haptic feedback to the play/pause button. mPlayPauseButtonBackground.setHapticFeedbackEnabled(true); mPlayPauseButton.setHapticFeedbackEnabled(true); }
From source file:org.apache.cordova.CordovaActivity.java
protected void init() { appView = makeWebView();//ww w . j a v a 2 s . co m createViews(); if (!appView.isInitialized()) { appView.init(cordovaInterface, pluginEntries, preferences); } cordovaInterface.onCordovaInit(appView.getPluginManager()); // Wire the hardware volume controls to control media if desired. String volumePref = preferences.getString("DefaultVolumeStream", ""); if ("media".equals(volumePref.toLowerCase(Locale.ENGLISH))) { setVolumeControlStream(AudioManager.STREAM_MUSIC); } }
From source file:com.google.android.apps.forscience.whistlepunk.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (showRequiredScreensIfNeeded()) { return;/*from w ww . ja v a2s . c om*/ } setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); } mSpinner = (Spinner) findViewById(R.id.spinner_nav); mDrawerLayout = (MultiTouchDrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.color_primary_dark)); mNavigationView = (NavigationView) findViewById(R.id.navigation); mNavigationView.setNavigationItemSelectedListener(this); // Only show dev testing options for (1) user-debug devices (2) debug APK builds if (DevOptionsFragment.shouldHideTestingOptions(this)) { mNavigationView.getMenu().removeItem(R.id.dev_testing_options); } mFeedbackProvider = WhistlePunkApplication.getFeedbackProvider(this); Bundle extras = getIntent().getExtras(); int selectedNavItemId = R.id.navigation_item_observe; int savedItemId = getSavedItemId(savedInstanceState); if (savedItemId != NO_SELECTED_ITEM) { selectedNavItemId = savedItemId; } else if (extras != null) { selectedNavItemId = extras.getInt(ARG_SELECTED_NAV_ITEM_ID, R.id.navigation_item_observe); } MenuItem item = mNavigationView.getMenu().findItem(selectedNavItemId); if (item == null) { selectedNavItemId = R.id.navigation_item_observe; item = mNavigationView.getMenu().findItem(selectedNavItemId); } mNavigationView.setCheckedItem(selectedNavItemId); onNavigationItemSelected(item); mRecordingStateListener = new RecorderController.RecordingStateListener() { @Override public void onRecordingStateChanged(RecordingMetadata recording) { mNavigationView.getMenu().findItem(R.id.navigation_item_projects).setEnabled(recording == null); mIsRecording = recording != null; exitMetadataIfNeeded(); } @Override public void onRecordingStartFailed(@RecorderController.RecordingStartErrorType int errorType) { } @Override public void onRecordingStopFailed( @RecorderController.RecordingStopErrorType int recordingStateErrorType) { } }; setVolumeControlStream(AudioManager.STREAM_MUSIC); }
From source file:org.awesomeapp.messenger.ui.GalleryListItem.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void onClickMediaIcon(String mimeType, Uri mediaUri) { if (SecureMediaStore.isVfsUri(mediaUri)) { if (mimeType.startsWith("image")) { Intent intent = new Intent(context, ImageViewActivity.class); intent.putExtra(ImageViewActivity.URI, mediaUri.toString()); intent.putExtra(ImageViewActivity.MIMETYPE, mimeType); context.startActivity(intent); return; }/* w w w .j ava2 s . c o m*/ return; } else { String body = convertMediaUriToPath(mediaUri); if (body == null) body = new File(mediaUri.getPath()).getAbsolutePath(); if (mimeType.startsWith("audio") || (body.endsWith("3gp") || body.endsWith("3gpp") || body.endsWith("amr"))) { if (mMediaPlayer != null) mMediaPlayer.release(); try { mMediaPlayer = new MediaPlayer(); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setDataSource(body); mMediaPlayer.prepare(); mMediaPlayer.start(); return; } catch (IOException e) { Log.e(ImApp.LOG_TAG, "error playing audio: " + body, e); } } Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (Build.VERSION.SDK_INT >= 11) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); //set a general mime type not specific intent.setDataAndType(Uri.parse(body), mimeType); Context context = getContext().getApplicationContext(); if (isIntentAvailable(context, intent)) { context.startActivity(intent); } else { Toast.makeText(getContext(), R.string.there_is_no_viewer_available_for_this_file_format, Toast.LENGTH_LONG).show(); } } }
From source file:com.cyanogenmod.eleven.ui.fragments.AudioPlayerFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Control the media volume getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); // Bind Apollo's service mToken = MusicUtils.bindToService(getActivity(), this); // Initialize the image fetcher/cache mImageFetcher = ApolloUtils.getImageFetcher(getActivity()); // Initialize the handler used to update the current time mTimeHandler = new TimeHandler(this); // Initialize the broadcast receiver mPlaybackStatus = new PlaybackStatus(this); // add a listener for the sliding ((SlidingPanelActivity) getActivity()).addSlidingPanelListener(this); // check equalizer view checkEqualizerView();/*from ww w. j a va 2s .c o m*/ }
From source file:com.andrew.apollo.ui.activities.AudioPlayerActivity.java
/** * {@inheritDoc}/* w w w. ja v a 2 s.c om*/ */ @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Title bar shows up in gingerbread, I'm too tired to figure out why. if (!ApolloUtils.hasHoneycomb()) { requestWindowFeature(Window.FEATURE_NO_TITLE); } // Initialze the theme resources mResources = new ThemeUtils(this); // Set the overflow style mResources.setOverflowStyle(this); // Fade it in overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); // Control the media volume setVolumeControlStream(AudioManager.STREAM_MUSIC); // Bind Apollo's service mToken = MusicUtils.bindToService(this, this); // Initialize the image fetcher/cache mImageFetcher = ApolloUtils.getImageFetcher(this); // Initialize the handler used to update the current time mTimeHandler = new TimeHandler(this); // Initialize the broadcast receiver mPlaybackStatus = new PlaybackStatus(this); // Theme the action bar final ActionBar actionBar = getSupportActionBar(); mResources.themeActionBar(actionBar, getString(R.string.app_name)); actionBar.setDisplayHomeAsUpEnabled(true); // Set the layout setContentView(R.layout.activity_player_base); // Cache all the items initPlaybackControls(); }
From source file:com.microntek.music.fragments.AudioPlayerFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Control the media volume getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); // Bind Apollo's service mToken = MusicUtils.bindToService(getActivity(), this); // Initialize the image fetcher/cache mImageFetcher = ApolloUtils.getImageFetcher(getActivity()); // Initialize the handler used to update the current time mTimeHandler = new TimeHandler(this); // Initialize the broadcast receiver mPlaybackStatus = new PlaybackStatus(this); }