List of usage examples for android.media MediaPlayer MediaPlayer
public MediaPlayer()
From source file:hku.fyp14017.blencode.ui.controller.SoundController.java
private void handleSoundInfo(SoundViewHolder holder, SoundInfo soundInfo, SoundBaseAdapter soundAdapter, int position, Context context) { try {/*from ww w. j a va2s . c om*/ MediaPlayer tempPlayer = new MediaPlayer(); tempPlayer.setDataSource(soundInfo.getAbsolutePath()); tempPlayer.prepare(); long milliseconds = tempPlayer.getDuration(); long seconds = milliseconds / 1000; if (seconds == 0) { seconds = 1; } String timeDisplayed = DateUtils.formatElapsedTime(seconds); holder.timePlayedChronometer.setText(timeDisplayed); holder.timePlayedChronometer.setVisibility(Chronometer.VISIBLE); if (soundAdapter.getCurrentPlayingPosition() == Constants.NO_POSITION) { SoundBaseAdapter.setElapsedMilliSeconds(0); } else { SoundBaseAdapter.setElapsedMilliSeconds( SystemClock.elapsedRealtime() - SoundBaseAdapter.getCurrentPlayingBase()); } if (soundInfo.isPlaying) { holder.playAndStopButton.setImageResource(hku.fyp14017.blencode.R.drawable.ic_media_stop); holder.playAndStopButton .setContentDescription(context.getString(hku.fyp14017.blencode.R.string.sound_stop)); if (soundAdapter.getCurrentPlayingPosition() == Constants.NO_POSITION) { startPlayingSound(holder.timePlayedChronometer, position, soundAdapter); } else if ((position == soundAdapter.getCurrentPlayingPosition()) && (SoundBaseAdapter.getElapsedMilliSeconds() > (milliseconds - 1000))) { stopPlayingSound(soundInfo, holder.timePlayedChronometer, soundAdapter); } else { continuePlayingSound(holder.timePlayedChronometer, SystemClock.elapsedRealtime()); } } else { holder.playAndStopButton.setImageResource(hku.fyp14017.blencode.R.drawable.ic_media_play); holder.playAndStopButton .setContentDescription(context.getString(hku.fyp14017.blencode.R.string.sound_play)); stopPlayingSound(soundInfo, holder.timePlayedChronometer, soundAdapter); } tempPlayer.reset(); tempPlayer.release(); } catch (IOException ioException) { Log.e(TAG, "Cannot get view.", ioException); } }
From source file:com.kiandastream.musicplayer.MusicService.java
/** * Makes sure the media player exists and has been reset. This will create the media player * if needed, or reset the existing media player if one already exists. *///w w w . ja v a 2 s. co m void createMediaPlayerIfNeeded() { if (mPlayer == null) { mPlayer = new MediaPlayer(); System.out.println("i am in creating meida player "); // Make sure the media player will acquire a wake-lock while playing. If we don't do // that, the CPU might go to sleep while the song is playing, causing playback to stop. // // Remember that to use this, we have to declare the android.permission.WAKE_LOCK // permission in AndroidManifest.xml. mPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); // we want the media player to notify us when it's ready preparing, and when it's done // playing: mPlayer.setOnPreparedListener(this); mPlayer.setOnCompletionListener(this); mPlayer.setOnBufferingUpdateListener(this); mPlayer.setOnErrorListener(this); } else mPlayer.reset(); }
From source file:github.popeen.dsub.service.DownloadService.java
@Override public void onCreate() { super.onCreate(); final SharedPreferences prefs = Util.getPreferences(this); new Thread(new Runnable() { public void run() { Looper.prepare();/*from w w w .j a v a 2s .c o m*/ mediaPlayer = new MediaPlayer(); mediaPlayer.setWakeMode(DownloadService.this, PowerManager.PARTIAL_WAKE_LOCK); // We want to change audio session id's between upgrading Android versions. Upgrading to Android 7.0 is broken (probably updated session id format) audioSessionId = -1; int id = prefs.getInt(Constants.CACHE_AUDIO_SESSION_ID, -1); int versionCode = prefs.getInt(Constants.CACHE_AUDIO_SESSION_VERSION_CODE, -1); if (versionCode == Build.VERSION.SDK_INT && id != -1) { try { audioSessionId = id; mediaPlayer.setAudioSessionId(audioSessionId); } catch (Throwable e) { Log.w(TAG, "Failed to use cached audio session", e); audioSessionId = -1; } } if (audioSessionId == -1) { mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { audioSessionId = mediaPlayer.getAudioSessionId(); SharedPreferences.Editor editor = prefs.edit(); editor.putInt(Constants.CACHE_AUDIO_SESSION_ID, audioSessionId); editor.putInt(Constants.CACHE_AUDIO_SESSION_VERSION_CODE, Build.VERSION.SDK_INT); editor.commit(); } catch (Throwable t) { // Froyo or lower } } mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mediaPlayer, int what, int more) { handleError(new Exception("MediaPlayer error: " + what + " (" + more + ")")); return false; } }); /*try { Intent i = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION); i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, audioSessionId); i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(i); } catch(Throwable e) { // Froyo or lower }*/ effectsController = new AudioEffectsController(DownloadService.this, audioSessionId); if (prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false)) { getEqualizerController(); } mediaPlayerLooper = Looper.myLooper(); mediaPlayerHandler = new Handler(mediaPlayerLooper); if (runListenersOnInit) { onSongsChanged(); onSongProgress(); onStateUpdate(); } Looper.loop(); } }, "DownloadService").start(); Util.registerMediaButtonEventReceiver(this); audioNoisyReceiver = new AudioNoisyReceiver(); registerReceiver(audioNoisyReceiver, audioNoisyIntent); if (mRemoteControl == null) { // Use the remote control APIs (if available) to set the playback state mRemoteControl = RemoteControlClientBase.createInstance(); ComponentName mediaButtonReceiverComponent = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()); mRemoteControl.register(this, mediaButtonReceiverComponent); } PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName()); wakeLock.setReferenceCounted(false); WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "downloadServiceLock"); try { timerDuration = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_SLEEP_TIMER_DURATION, "5")); } catch (Throwable e) { timerDuration = 5; } sleepTimer = null; keepScreenOn = prefs.getBoolean(Constants.PREFERENCES_KEY_KEEP_SCREEN_ON, false); mediaRouter = new MediaRouteManager(this); instance = this; shufflePlayBuffer = new ShufflePlayBuffer(this); artistRadioBuffer = new ArtistRadioBuffer(this); lifecycleSupport.onCreate(); if (Build.VERSION.SDK_INT >= 26) { Notifications.shutGoogleUpNotification(this); } }
From source file:fm.krui.kruifm.StreamService.java
/** * Builds and returns a configured, unprepared MediaPlayer and attach an error handler. */// ww w. java2 s. co m public MediaPlayer buildAudioPlayer() { // Build MediaPlayer mp = new MediaPlayer(); try { mp.reset(); mp.setAudioStreamType(AudioManager.STREAM_MUSIC); mp.setDataSource(streamUrl); } catch (IllegalArgumentException e) { Log.e(TAG, "Caught IllegalArgumentException: "); e.printStackTrace(); } catch (IllegalStateException e) { Log.e(TAG, "Caught IllegalStateException: "); e.printStackTrace(); } catch (SecurityException e) { Log.e(TAG, "Caught SecurityException: "); e.printStackTrace(); } catch (IOException e) { Log.e(TAG, "Caught IOException: "); e.printStackTrace(); } // Attach error handler to instance. /*mp.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer arg0, int arg1, int arg2) { // If there is an error in playback, stop and inform the user. mp = buildAudioPlayer(); // FIXME: This should be a status bar message! Update this when that is fully implemented Toast.makeText(getApplicationContext(), "Failed to load the stream. Please check your internet connection and try again.", Toast.LENGTH_LONG).show(); Log.e(TAG, "Error in playback. onError is being called."); return true; } });*/ return mp; }
From source file:net.wespot.pim.view.InqImageDetailFragment.java
public void preparePlayer() { if (mediaPlayer == null) { mediaPlayer = new MediaPlayer(); }//from www . j a va2 s . c o m mediaPlayer.reset(); oneTimeOnly = 0; status = PAUSE; try { Uri uri = Uri.parse(mAudioUrl); mediaPlayer.setDataSource(getActivity(), uri); mediaPlayer.prepare(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.xlythe.engine.theme.Theme.java
public static long getDurationOfSound(Context context, Theme.Res res) { int millis = 0; MediaPlayer mp = new MediaPlayer(); try {/*from w ww .j a v a2 s. co m*/ AssetFileDescriptor afd; int id = getId(context, res.getType(), res.getName()); if (id == 0) { id = context.getResources().getIdentifier(res.getName(), res.getType(), context.getPackageName()); afd = context.getResources().openRawResourceFd(id); } afd = getThemeContext(context).getResources().openRawResourceFd(id); mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); afd.close(); mp.prepare(); millis = mp.getDuration(); } catch (Exception e) { e.printStackTrace(); } finally { mp.release(); mp = null; } return millis; }
From source file:com.example.android.leanback.MediaSessionService.java
/** * Prepare the first item in the list. And setup the listener for media player. *///from ww w .j a v a2 s. c om private void initializePlayer() { // This service can be created for multiple times, the objects will only be created when // it is null if (mPlayer != null) { return; } mPlayer = new MediaPlayer(); // Set playback state to none to create a valid playback state. So controls row can get // information about the supported actions. mMediaSession.setPlaybackState(createPlaybackStateBuilder(PlaybackStateCompat.STATE_NONE).build()); // Activate media session if (!mMediaSession.isActive()) { mMediaSession.setActive(true); } // Set up listener and audio stream type for underlying music player. mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); // set up listener when the player is prepared. mPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mInitialized = true; // Every time when the player is prepared (when new data source is set), // all listeners will be notified to toggle the UI to "pause" status. notifyUiWhenPlayerIsPrepared(); // When media player is prepared, the callback functions will be executed to update // the meta data and playback state. onMediaSessionMetaDataChanged(); mMediaSession .setPlaybackState(createPlaybackStateBuilder(PlaybackStateCompat.STATE_PAUSED).build()); } }); // set up listener for player's error. mPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mediaPlayer, int what, int extra) { if (DEBUG) { PlaybackStateCompat.Builder builder = createPlaybackStateBuilder( PlaybackStateCompat.STATE_ERROR); builder.setErrorMessage(PlaybackStateCompat.ERROR_CODE_APP_ERROR, MEDIA_PLAYER_ERROR_MESSAGE); mMediaSession.setPlaybackState(builder.build()); } return true; } }); // set up listener to respond the event when current music item is finished mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { /** * Expected Interaction Behavior: * 1. If current media item's playing speed not equal to normal speed. * * A. MEDIA_ACTION_REPEAT_ALL * a. If current media item is the last one. The first music item in the list will * be prepared, but it won't play until user press play button. * * When user press the play button, the speed will be reset to normal (1.0f) * no matter what the previous media item's playing speed is. * * b. If current media item isn't the last one, next media item will be prepared, * but it won't play. * * When user press the play button, the speed will be reset to normal (1.0f) * no matter what the previous media item's playing speed is. * * B. MEDIA_ACTION_REPEAT_ONE * Different with previous scenario, current item will go back to the start point * again and play automatically. (The reason to enable auto play here is for * testing purpose and to make sure our designed API is flexible enough to support * different situations.) * * No matter what the previous media item's playing speed is, in this situation * current media item will be replayed in normal speed. * * C. MEDIA_ACTION_REPEAT_NONE * a. If current media is the last one. The service will be closed, no music item * will be prepared to play. From the UI perspective, the progress bar will not * be reset to the starting point. * * b. If current media item isn't the last one, next media item will be prepared, * but it won't play. * * When user press the play button, the speed will be reset to normal (1.0f) * no matter what the previous media item's playing speed is. * * @param mp Object of MediaPlayer */ @Override public void onCompletion(MediaPlayer mp) { // When current media item finishes playing, always reset rewind/ fastforward state mFastForwardSpeedFactorIndex = 0; mRewindSpeedFactorIndex = 0; // Set player's playback speed back to normal mPlayer.setPlaybackParams(mPlayer.getPlaybackParams() .setSpeed(mFastForwardSpeedFactors[mFastForwardSpeedFactorIndex])); // Pause the player, and update the status accordingly. mPlayer.pause(); mMediaSession .setPlaybackState(createPlaybackStateBuilder(PlaybackStateCompat.STATE_PAUSED).build()); if (mRepeatState == MEDIA_ACTION_REPEAT_ALL && mCurrentIndex == mMediaItemList.size() - 1) { // if the repeat mode is enabled but the shuffle mode is not enabled, // will go back to the first music item to play if (mShuffleMode == PlaybackStateCompat.SHUFFLE_MODE_NONE) { mCurrentIndex = 0; } else { // Or will choose a music item from playing list randomly. mCurrentIndex = generateMediaItemIndex(); } mCurrentMediaItem = mMediaItemList.get(mCurrentIndex); // The ui will also be changed from playing state to pause state through // setDataSource() operation setDataSource(); } else if (mRepeatState == MEDIA_ACTION_REPEAT_ONE) { // Play current music item again. // The ui will stay to be "playing" status for the reason that there is no // setDataSource() function call. mPlayer.start(); mMediaSession.setPlaybackState( createPlaybackStateBuilder(PlaybackStateCompat.STATE_PLAYING).build()); } else if (mCurrentIndex < mMediaItemList.size() - 1) { if (mShuffleMode == PlaybackStateCompat.SHUFFLE_MODE_NONE) { mCurrentIndex++; } else { mCurrentIndex = generateMediaItemIndex(); } mCurrentMediaItem = mMediaItemList.get(mCurrentIndex); // The ui will also be changed from playing state to pause state through // setDataSource() operation setDataSource(); } else { // close the service when the playlist is finished // The PlaybackState will be updated to STATE_STOPPED. And onPlayComplete // callback will be called by attached glue. mMediaSession.setPlaybackState( createPlaybackStateBuilder(PlaybackStateCompat.STATE_STOPPED).build()); stopSelf(); } } }); final MediaPlayer.OnBufferingUpdateListener mOnBufferingUpdateListener = new MediaPlayer.OnBufferingUpdateListener() { @Override public void onBufferingUpdate(MediaPlayer mp, int percent) { mBufferedProgress = getDuration() * percent / 100; PlaybackStateCompat.Builder builder = createPlaybackStateBuilder( PlaybackStateCompat.STATE_BUFFERING); builder.setBufferedPosition(mBufferedProgress); mMediaSession.setPlaybackState(builder.build()); } }; mPlayer.setOnBufferingUpdateListener(mOnBufferingUpdateListener); }
From source file:com.classiqo.nativeandroid_32bitz.playback.LocalPlayback.java
private void createMediaPlayerIfNeeded() { LogHelper.d(TAG, "createMediaPlayerIfNeeded. needed? ", (mMediaPlayer == null)); if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); mMediaPlayer.setWakeMode(mContext.getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnSeekCompleteListener(this); } else {/* w w w . j av a 2 s. co m*/ mMediaPlayer.reset(); } }
From source file:dev.datvt.cloudtracks.MainActivity.java
@Override protected void onResume() { Intent intent = getIntent();//from w w w . j av a2 s. c o m if (intent != null) { curPos = intent.getIntExtra("pos", curPos); curPos = NotificationUtil.position; if (MediaPlayerService.tracks != null) { Log.d("INTENT", "OPEN_BY_NOTI"); tracks = MediaPlayerService.tracks; if (tracks.size() > curPos) { curTrack = tracks.get(curPos); updateSong(); } } if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); } } try { loading.progressiveStop(); loading.setVisibility(View.INVISIBLE); } catch (Exception e) { e.printStackTrace(); } editor.putBoolean("isLive", true); editor.commit(); super.onResume(); }
From source file:com.rainmakerlabs.bleepsample.BleepService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand"); String actionName = intent.getStringExtra("actionName"); if (intent == null || intent.getExtras() == null) {//just removing these checks } else if (actionName.equalsIgnoreCase(BLEepService.INTENT_BLEEP_PROCESS) && intent.getExtras().containsKey(BLEepService.INTENT_BLEEP_PASSED_LIST)) { ArrayList<Bleep> bleeps = (ArrayList<Bleep>) intent.getExtras() .getSerializable(BLEepService.INTENT_BLEEP_PASSED_LIST); for (final Bleep bleep : bleeps) { String msgType = bleep.getType(); String atts = bleep.getAtts(); try { JSONObject objMsg = new JSONObject(atts); //thisBleepService.addExtraLog(bleep, "FEEDBACK", "good");//use this when you want to send a custom log to BMS. for instance, you could display a feedback dialog, and ask users to give a rating, and BMS will help you collate the information. put this where necessary, it's just here for example Log.d(TAG, "Message Received of Type: " + msgType); if (msgType.equalsIgnoreCase("image")) { final String strImgUrl = objMsg.optString(APIKeyDefineCommand.MSG_IMG); final String adAspect = objMsg.optString(APIKeyDefineCommand.MSG_IMGASP); String strImgMsgTemp = objMsg.optString(APIKeyDefineCommand.MSG_NOTIF); //putting the default message above would only work for missing key, not in case of empty string. empty string will prevent the notification, so fix below if (strImgMsgTemp.equalsIgnoreCase("")) strImgMsgTemp = "No Message"; final String strImgMsg = strImgMsgTemp; if (checkIfClosed()) { if (oldcodeon) localNotification("", strImgMsg, 0); continue; }//from w w w . j a v a 2s .c o m if (MainActivity.adlib.get(strImgMsg) == null && !strImgMsg.equalsIgnoreCase("No Message")) Log.d(TAG, "image url start download for key: " + strImgMsg + ", url = " + strImgUrl); else { Log.d(TAG, "Image exists, or no message, not downloading..., key: " + strImgMsg); continue; } if (strImgMsg.equalsIgnoreCase("$28")) { Log.d("Portal", "Image exists, loading from cache"); imgShow(BitmapFactory.decodeResource(getResources(), R.drawable.singtel), strImgMsg); continue; } else if (strImgMsg.equalsIgnoreCase("$4.50")) { Log.d("Portal", "Heineken Image exists, loading from cache"); imgShow(BitmapFactory.decodeResource(getResources(), R.drawable.heineken), strImgMsg); continue; } ShutterbugManager.getSharedImageManager(BleepActivity.currentBleepActivity) .download(strImgUrl, new ShutterbugManagerListener() { @Override public void onImageSuccess(ShutterbugManager imageManager, Bitmap bitmap, String url) { Log.d(TAG, "image url end download " + strImgUrl); if (strImgUrl.equalsIgnoreCase(AdDialog.getCurrentAdUrl())) return; if (AdDialog.howManyAdDialogsShowing == 1) { AdDialog.closeOnlyAdDialog(); } final Bitmap bitmap2 = bitmap; imgShow(bitmap, strImgMsg); if (oldcodeon) { BleepActivity.currentBleepActivity.runOnUiThread(new Runnable() { public void run() { if (BleepActivity.isBackground) localNotification("", strImgMsg, 0); AdDialog.showAdsDialog(BleepActivity.currentBleepActivity, bitmap2, strImgUrl, adAspect); } }); } } @Override public void onImageFailure(ShutterbugManager imageManager, String url) { thisBleepService.eraseTriggerLog(bleep);//to cancel trigger log when trigger is cancelled } }); } else if (oldcodeon == false) {//don't run anything else } else if (msgType.equalsIgnoreCase("alert") && oldcodeon) { // show alert message if (checkIfClosed() || BleepActivity.isBackground) { localNotification(objMsg.optString(APIKeyDefineCommand.MSG_TITLE), objMsg.optString(APIKeyDefineCommand.MSG_CONTENT), 1); } else { showAlert(objMsg.optString(APIKeyDefineCommand.MSG_TITLE), objMsg.optString(APIKeyDefineCommand.MSG_CONTENT)); } } else if (msgType.equalsIgnoreCase("launch")) { String intentAction = objMsg.optString(APIKeyDefineCommand.MSG_APP_INTENT); String intentUri = objMsg.optString(APIKeyDefineCommand.MSG_APP_URI); String intentType = ""; String intentExtras = objMsg.optString(APIKeyDefineCommand.MSG_APP_EXTRAS); String cfmMsg = objMsg.optString(APIKeyDefineCommand.MSG_APP_CFM); String failMsg = objMsg.optString(APIKeyDefineCommand.MSG_APP_FAIL); processTypeLaunch(intentAction, intentUri, intentType, intentExtras, cfmMsg, failMsg, 2); } else if (msgType.equalsIgnoreCase("url")) { String intentAction = Intent.ACTION_VIEW; String intentUri = objMsg.optString(APIKeyDefineCommand.MSG_MEDIA_URL); String intentType = ""; String intentExtras = ""; String cfmMsg = objMsg.optString(APIKeyDefineCommand.MSG_APP_CFM); String failMsg = objMsg.optString(APIKeyDefineCommand.MSG_APP_FAIL); processTypeLaunch(intentAction, intentUri, intentType, intentExtras, cfmMsg, failMsg, 3); } else if (msgType.equalsIgnoreCase("webview")) { String intentAction = Intent.ACTION_VIEW; String intentUri = objMsg.optString(APIKeyDefineCommand.MSG_MEDIA_URL); String intentType = ""; String intentExtras = ""; String cfmMsg = objMsg.optString(APIKeyDefineCommand.MSG_NOTIF); if (cfmMsg.equalsIgnoreCase("")) cfmMsg = "View webpage?"; String failMsg = ""; processTypeLaunch(intentAction, intentUri, intentType, intentExtras, cfmMsg, failMsg, 4); } else if (msgType.equalsIgnoreCase("video")) { String strVidUrl = objMsg.optString(APIKeyDefineCommand.MSG_MEDIA_URL); Intent vidIntent = new Intent(this, VideoActivity.class); vidIntent.putExtra("url", strVidUrl); String notifMsg = objMsg.optString(APIKeyDefineCommand.MSG_NOTIF); if (notifMsg.equalsIgnoreCase("")) notifMsg = "Play video?"; if (!checkIfClosed() && BleepActivity.isVideoActivityOpen) { thisBleepService.eraseTriggerLog(bleep);//to cancel trigger log when trigger is cancelled } else if (checkIfClosed() || BleepActivity.isBackground) { vidIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); vidIntent.setAction(Intent.ACTION_MAIN); vidIntent.addCategory(Intent.CATEGORY_LAUNCHER); localNotification("", notifMsg, vidIntent, "Video opening failed!", 5); } else { BleepActivity.currentBleepActivity.startActivity(vidIntent); } } else if (msgType.equalsIgnoreCase("audio")) { String url = objMsg.optString(APIKeyDefineCommand.MSG_MEDIA_URL); mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(url); } catch (IOException e) { e.printStackTrace(); } mediaPlayer.prepareAsync(); mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.start(); } }); mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { return false; } }); } } catch (JSONException e) { e.printStackTrace(); } } // } else if (actionName.equalsIgnoreCase(BLEepService.INTENT_BLEEP_EXIT) && intent.getExtras().containsKey(BLEepService.INTENT_MSG_NAME)) { // HashMap<String, Object> beaconOutInfo = (HashMap<String, Object>)intent.getSerializableExtra(BLEepService.INTENT_MSG_NAME); // //Log.d("debug!","debug! this beacon just went out "+beaconOutInfo.get("uuid")+" "+beaconOutInfo.get("major")+" "+beaconOutInfo.get("minor")+" "+beaconOutInfo.get("tag")+" "+beaconOutInfo.get("beaconID")); } else if (actionName.equalsIgnoreCase(BLEepService.INTENT_BLEEP_STATE) && intent.getExtras().containsKey(BLEepService.INTENT_MSG_NAME)) { int beaconState = intent.getIntExtra(BLEepService.INTENT_MSG_NAME, 99); } return START_NOT_STICKY; }