Code example for TimeUnit

Methods: sleep, toMillis

0
	if (song != null && (file = new File(song)).exists()) {
	    // play song first 
    	    mPlayer = MediaPlayer.create(this, Uri.fromFile(file));
    	    mPlayer.start();
    	    try { 
		Thread.sleep(TimeUnit.SECONDS.toMillis(songDuration));
	    } catch (InterruptedException e) { /* shouldn't happen */ }
    	    mPlayer.stop();
    	    try { 
		Thread.sleep(1000); // pause between music stop and TTS
	    } catch (InterruptedException e) { /* shouldn't happen */ }
    	    speak(); 
	} else { 
	    // just speak 
	    speak(); 
	} 
    } 
     
    private void speak() { 
	HashMap<String, String> params = new HashMap<String, String>();
    	params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "meaninglessString");