public void startRingback(final String ringbackUriType){
  if (ringbackUriType.isEmpty()) {
    return;
  }
  try {
    Log.d(TAG,"startRingback(): UriType=" + ringbackUriType);
    if (mRingback != null) {
      if (mRingback.isPlaying()) {
        Log.d(TAG,"startRingback(): is already playing");
        return;
      }
 else {
        stopRingback();
      }
    }
    Uri ringbackUri;
    Map data=new HashMap<String,Object>();
    data.put("name","mRingback");
    if (ringbackUriType.equals("_DTMF_")) {
      mRingback=new myToneGenerator(myToneGenerator.RINGBACK);
      mRingback.startPlay(data);
      return;
    }
 else {
      ringbackUri=getRingbackUri(ringbackUriType);
      if (ringbackUri == null) {
        Log.d(TAG,"startRingback(): no available media");
        return;
      }
    }
    mRingback=new myMediaPlayer();
    data.put("sourceUri",ringbackUri);
    data.put("setLooping",true);
    data.put("audioStream",AudioManager.STREAM_VOICE_CALL);
    setMediaPlayerEvents((MediaPlayer)mRingback,"mRingback");
    mRingback.startPlay(data);
  }
 catch (  Exception e) {
    Log.d(TAG,"startRingback() failed");
  }
}

public void startRingback ( final String ringbackUriType ) { if ( ringbackUriType . isEmpty ( ) ) { return ; } try { Log . d ( TAG , "startRingback(): UriType=" + ringbackUriType ) ; if ( mRingback != null ) { if ( mRingback . isPlaying ( ) ) { Log . d ( TAG , "startRingback(): is already playing" ) ; return ; } else { stopRingback ( ) ; } } Uri ringbackUri ; Map data = new HashMap < String , Object > ( ) ; data . put ( "name" , "mRingback" ) ; if ( ringbackUriType . equals ( "_DTMF_" ) ) { mRingback = new myToneGenerator ( myToneGenerator . RINGBACK ) ; mRingback . startPlay ( data ) ; return ; } else { ringbackUri = getRingbackUri ( ringbackUriType ) ; if ( ringbackUri == null ) { Log . d ( TAG , "startRingback(): no available media" ) ; return ; } } mRingback = new myMediaPlayer ( ) ; data . put ( "sourceUri" , ringbackUri ) ; data . put ( "setLooping" , true ) ; data . put ( "audioStream" , AudioManager . STREAM_VOICE_CALL ) ; setMediaPlayerEvents ( ( MediaPlayer ) mRingback , "mRingback" ) ; mRingback . startPlay ( data ) ; } catch ( Exception e ) { Log . d ( TAG , "startRingback() failed" ) ; } }
this is part of start ( ) process . ringbackuritype must not empty . empty means do not play .
