Android TextToSpeach播放器没有播放声音

时间:2017-08-23 12:21:27

标签: android

嗨我有一个按钮从中调用给定的方法问题是当我第一次单击按钮时TextToSpeach播放器不播放声音但处理程序代码执行完美。如果我再次点击按钮一切正常工作意味着TextToSpeach播放声音。谢谢..

  public void selectDest() {
                TextToSpeechPlayer.playSound("hello");
                new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                Log.d(TAG, "After 1 sec  ");
                                }
                        },1000);
            }

2 个答案:

答案 0 :(得分:0)

试试这个

TextToSpeechPlayer.playSound("hello");
      handler = new Handler();
            runnable = new Runnable() {
                public void run() {

    //do your other task here
                    handler.postDelayed(this, 60 * 1000);
                }
            };
            handler.postDelayed(runnable, 0);

答案 1 :(得分:0)

public void selectDest() {

            new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
            TextToSpeechPlayer.playSound("hello");
                            Log.d(TAG, "After 1 sec  ");
                            }
                    },1000);
        }