Ringtone.stop() wont work?

All your problems with Audio, Video and Images.

Ringtone.stop() wont work?

Postby Draffodx » Mon Mar 01, 2010 10:22 am

I currently start a Ringtone on Android and it plays fine.

However when I try to stop the ringtone it doesn't stop or atleast
doesn't stop straight away, it will keep in playing until it just
plays out.

Here is how I set up the Ringtone:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. int rm = audio_service.getRingerMode();
  2.  
  3. int vs =
  4.  
  5. audio_service.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
  6.  
  7.  
  8.  
  9. android.os.Vibrator v = (Vibrator)
  10.  
  11. getSystemService(Context.VIBRATOR_SERVICE);
  12.  
  13.  
  14.  
  15. if ((rm == AudioManager.RINGER_MODE_VIBRATE ||
  16.  
  17.     (rm == AudioManager.RINGER_MODE_NORMAL && vs ==
  18.  
  19. AudioManager.VIBRATE_SETTING_ON)))
  20.  
  21.             v.vibrate(vibratePattern,1);
  22.  
  23.  
  24.  
  25. if (audio_service.getStreamVolume(AudioManager.STREAM_RING) > 0)
  26.  
  27. {
  28.  
  29.  
  30.  
  31.     oRingtone = RingtoneManager.getRingtone(this,
  32.  
  33. Settings.System.DEFAULT_RINGTONE_URI);
  34.  
  35.     oRingtone.setStreamType(AudioManager.STREAM_RING);
  36.  
  37.     oRingtone.play();
  38.  
  39.  
  40.  
  41.     }
  42.  
  43.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


And here is how I try to stop it

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. if (CallDialogActivity.oRingtone != null) {
  2.  
  3.       Log.d("RINGTONE", "Into Ringtone if");
  4.  
  5.       Ringtone ringtone = CallDialogActivity.oRingtone;
  6.  
  7.       oRingtone = null;
  8.  
  9.       ringtone.stop();
  10.  
  11.  
  12.  
  13. }
  14.  
  15.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Has anyone come across similiar problems or see any mistakes in my
code?
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Postby senormoll » Wed Mar 03, 2010 3:48 pm

Where is the code that you are using to stop it? A separate Activity? Why declare a new Ringtone object?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Ringtone ringtone = CallDialogActivity.oRingtone;
  3.  
  4.       oRingtone = null;
  5.  
  6.       ringtone.stop();
  7.  
  8.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
senormoll
Developer
Developer
 
Posts: 29
Joined: Tue Feb 23, 2010 2:50 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 11 guests