@Override public IVoiceCommand execute() { super.execute(); // TODO Auto-generated method stub getUnion().getTTSController().play("不好意思,没有找到这个故事,将会随机帮您找个故事"); getUnion() .getTTSController() .setListener( new ITTSStateListener() { @Override public void onStart() { // TODO Auto-generated method stub } @Override public void onInit() { // TODO Auto-generated method stub } @Override public void onError() { // TODO Auto-generated method stub } @Override public void onEnd() { // TODO Auto-generated method stub LogManager.e("test"); getUnion().getCommandEngine().handleText("故事"); getUnion().getTTSController().setListener(null); } }); return null; }
@Override public IVoiceCommand execute() { super.execute(); // TODO Auto-generated method stub String arg = mInfo.getArg(0); LogManager.i(TAG, "execute -----info:" + arg); // 记录歌曲命令开始执行的时间 SupKeyList.COMMAND_START_EXECUTE = System.currentTimeMillis(); int commandType = -1; if (mParamMap.containsKey(arg)) { commandType = Integer.valueOf(mParamMap.get(arg)); // TODO Intent i = new Intent(); if (commandType >= MusicUtil.COMMAND_NEXT && commandType <= MusicUtil.COMMAND_RANDOM) { mAirPlayMusicController.setAirplay(false); mAirPlayMusicController.stop(); this.getUnion().getRecogniseSystem().startWakeup(); } LogManager.i(TAG, "current commandType:" + commandType); switch (commandType) { case MusicUtil.COMMAND_EXIT: // TODO:如果添加停止音乐方法可能会影响到播放器状态,暂时改为暂停播放当前音乐 getUnion().getMediaInterface().pause(); mBaseContext.setGlobalLong("mediaPauseTime", System.currentTimeMillis()); mDlanMusicController.sendToDlanStop(); mAirPlayMusicController.stop(); this.getUnion().getRecogniseSystem().startWakeup(); break; case MusicUtil.COMMAND_STOP: if (mDlanMusicController.isDlan()) { LogManager.i(TAG, "dlna----------COMMAND_STOP---onpause"); mDlanMusicController.pause(); } else if (mAirPlayMusicController.isAirplay()) { LogManager.i(TAG, "airplay-----------COMMAND_STOP---onpause"); mAirPlayMusicController.pause(); } else { LogManager.i(TAG, "普通歌曲-----------COMMAND_STOP---onpause"); getUnion().getMediaInterface().pause(); mBaseContext.setGlobalLong("mediaPauseTime", System.currentTimeMillis()); } break; case MusicUtil.COMMAND_START: if (mDlanMusicController.isDlan()) { LogManager.i(TAG, "dlna----------COMMAND_START---play"); mDlanMusicController.paly(); } else if (mAirPlayMusicController.isAirplay()) { LogManager.i(TAG, "airplay----------COMMAND_START---play"); mAirPlayMusicController.play(); } else { LogManager.i(TAG, "普通歌曲----------COMMAND_START---play"); long distance = System.currentTimeMillis() - mBaseContext.getGlobalLong("mediaPauseTime"); if (distance > 3600000) { // 同一首歌暂停有效期为1小时 getUnion().getCommandEngine().handleText("唱歌"); return null; } else { getUnion().getMediaInterface().resume(); } } break; case MusicUtil.COMMAND_NEXT: forceNext(); MusicUtil.logMusic(commandType, mBaseContext); return null; case MusicUtil.COMMAND_PRE: MusicUtil.logMusic(commandType, mBaseContext); getUnion().getMediaInterface().playPre(); return null; case MusicUtil.COMMAND_RANDOM: // random not support MusicUtil.logMusic(commandType, mBaseContext); getUnion().getMediaInterface().playNext(); return null; case MusicUtil.COMMAND_CIRCLE: i.setAction(KeyList.PKEY_MUSIC_CIRCLE); getUnion().getMediaInterface().setPlayMode(IMediaInterface.PLAY_MODE_SIGNAL); sendAnswerSession("好的,进入单曲循环"); break; case MusicUtil.COMMAND_BAD: if (getUnion().getBaseContext().getGlobalBoolean(KeyList.GKEY_IS_MUSIC_IN_PLAYING)) { forceNext(); } MusicUtil.logMusic(commandType, mBaseContext); return null; case MusicUtil.COMMAND_GOOD: if (getUnion().getBaseContext().getGlobalBoolean(KeyList.GKEY_IS_MUSIC_IN_PLAYING)) { sendAnswerSession("收藏成功"); } MusicUtil.logMusic(commandType, mBaseContext); return null; default: break; } } MusicUtil.logMusic(commandType, mBaseContext); return null; }