我正在尝试使用GDK创建一个应用程序,使用MediaRecorder录制视频,使用眼睛手势控制它(开始录制,停止录制)。我可以使用双闪烁来调用MediaRecorder.start(),但从MediaRecorder启动的那一刻起,我就不会再收到眼睛事件了。
我使用here中的代码作为视频录制逻辑的基础,使用来自here的代码进行眼动手势捕获。
以下是实现侦听器启动/停止MediaRecorder的代码:
class EyeGestureReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
mAudioManager.playSoundEffect(Sounds.SUCCESS);
Bundle extras = intent.getExtras();
String eyeGesture = extras.getString("gesture");
boolean screenOff = extras.getBoolean("screen_off");
Log.d(TAG, eyeGesture + " is detected");
if (EyeGesture.DOUBLE_BLINK.toString().equals(eyeGesture)) {
if (isRecording) {
// stop recording and release camera
...
isRecording = false;
} else {
// Camera is available and unlocked, MediaRecorder is prepared,
// now you can start recording, startRecording will call MediaRecorder.start()
if (startRecording()) {
isRecording = true;
// from this point I don't receive more eye events
// onReceive is never fired again.
// I've tested without calling mediaRecorder.start()
// and in this scenario eye events are detected without problems
}
}
}
abortBroadcast();
}
}
在我的主要活动的onCreate方法中,我实例化它们:
mEyeGestureManager = EyeGestureManager.from(this);
mReceiver = new EyeGestureReceiver();
on onStart:
mEyeGestureManager.enableDetectorPersistently(EyeGesture.DOUBLE_BLINK, true);
mEyeGestureManager.enableDetectorPersistently(EyeGesture.WINK, true);
IntentFilter filter = new IntentFilter("com.google.glass.action.EYE_GESTURE");
filter.setPriority(2000);
有什么想法?
答案 0 :(得分:0)
EyeGesture的东西不是GDK的一部分,因为它还没有准备好,因此就像这样的bug。如果您使用,<。p>,预计整个系统会出现奇怪的行为