2

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...

DaChavoh
  • 100
  • 1
  • 16
  • The code is on top, It playing the video just that there's no voice command triggered when the video is playing – DaChavoh Mar 25 '15 at 09:25
  • Have you implemented [contextual voice commands](https://developers.google.com/glass/develop/gdk/voice#contextual_voice_commands)? – Koh Mar 25 '15 at 20:52
  • Yes, I did, It working with voice command, just that I want to add voice command while the video is playing....control video play with voice command...@Koh – DaChavoh Mar 26 '15 at 06:31

1 Answers1

2

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.

Koh
  • 1,570
  • 1
  • 8
  • 6
  • can you give me an example based on the above code I provided, because really I dont understand your answer. – DaChavoh Mar 27 '15 at 06:58
  • Take note that I am using VideoView instead of the `VIDEOPLAYER` activity. – Koh Mar 27 '15 at 16:22