Code example for Ringtone

Methods: isPlaying, play, stop

0
			boolean fromUser) {
	 
		if (!fromUser)
			return; 
		 
		if (mRingtone != null && !mRingtone.isPlaying())
			sampleOn(); 
 
		postVolumeChange(progress);
	} 
 
	private void postVolumeChange(int progress) {
		iLastVolume = progress;
		mHandler.removeCallbacks(null);
		mHandler.post(this);
		 
	} 
 
	@Override 
	public void onStartTrackingTouch(SeekBar seekBar) {
		 
	} 
 
	@Override 
	public void onStopTrackingTouch(SeekBar seekBar) {
		if (mRingtone != null && !mRingtone.isPlaying()) {
			sampleOn(); 
		} 
	} 
	 
	public void setVolume(int volume) {
		iVolume = volume;
	} 
	 
	public int getVolume() { 
			return iVolume;
	} 
	 
	public void setRingtone(Uri ringtoneUri) {
		mRingtoneUri = ringtoneUri;
	} 
 
	@Override 
	public void run() { 
		mAudioManager.setStreamVolume(iStreamType, iLastVolume, 0);
	} 
	 
	public void stop() { 
		sampleOff(); 
		mSeekBar.setOnSeekBarChangeListener(null);
	} 
	private void sampleOff() { 
		if (mRingtone != null )
			mRingtone.stop();
		 
	} 
 
	public void sampleOn() { 
		sampleOff(); 
		if (mRingtone != null && !mRingtone.isPlaying())
			mRingtone.play();
	} 
 
}