Reputation: 100
How do I add "ok glass" in my video while it playing, I have this code :
public void launchVideo(String filename) {
Log.e("Code checking","Welcome DUDE!!!");
//say(filename);
String path = mMovieDirectory+"/"+filename;
File file = new File(path);
if (!file.exists()) {
return;
}
Intent i = new Intent();
i.setAction("com.google.glass.action.VIDEOPLAYER");
i.putExtra("video_url", path);
startActivity(i);
}
I want to use a voice command to pause (not to touch or swipe it) the video or play the videos...
Upvotes: 2
Views: 193
Reputation: 1570
If it's a local file, you can use VideoView in your MainActivity. I have tested and can verify that using contextual voice commands works while the video is playing, and you can define your actions in onMenuItemSelected
.
First, add a VideoView to your activity's layout XML file. Next, define it in your method above as:
videoView = (VideoView) findViewById(R.id.video_view);
videoView.setMediaController(new MediaController(this));
videoView.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.<video file name>);
videoView.requestFocus();
videoView.start();
Enable contextual voice commands as mentioned in the docs. Add pause and resume actions in the onMenuItemSelected
method.
Upvotes: 2