1

I'm developing a Google Glass application which need to get videos from my phone and play it on my Google glass. Can anyone please help me to retrieve videos from my phone into Google glass.

I managed to retrieve videos from Glass and play it, here my code :

   private void play() {
            int position = mList.getSelectedItemPosition();

            if(mLength > 0 && position != -1) {
                int index = mMovieCursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
                mMovieCursor.moveToPosition(position);
                String videoLocationPath = mMovieCursor.getString(index);
                Uri videoLocation = Uri.parse(videoLocationPath);

                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(videoLocation, "video/*");
                getSoundManager().playSound(SoundId.VIDEO_START);
                startActivity(intent);
            } 

...................

and my loader

@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {
    switch(loaderId) {
    case URL_LOADER:
        String[] proj = { MediaStore.Video.Media._ID,
                MediaStore.Video.Media.ALBUM,
                MediaStore.Video.Media.BUCKET_DISPLAY_NAME,
                MediaStore.Video.Media.DATA,
                MediaStore.Video.Media.DISPLAY_NAME,
                MediaStore.Video.Media.SIZE };

        long bucketId = getIntent().getLongExtra(EXTRA_MOVIE_BUCKET, 0L);
        String selection = null;
        String[] selectionArgs = null;

        if(bucketId != 0) {
            selection = MediaStore.Video.Media.DATA + " not like ? and " + MediaStore.Video.Media.BUCKET_ID + " =? " ;
            selectionArgs = new String[] {"%sdcard/glass_cached_files%", Long.toString(bucketId) };
        } else {
            selection = MediaStore.Video.Media.DATA + " not like ? ";
            selectionArgs = new String[] { "sdcard/glass_cached_files%" };
        }

        return new CursorLoader(this, MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                proj, selection, selectionArgs, MediaStore.Video.Media.DISPLAY_NAME);

    default:
        return null;
    }
}

Thanks in advance

mpromonet
  • 11,326
  • 43
  • 62
  • 91
DaChavoh
  • 100
  • 1
  • 16

1 Answers1

0

One option you have is to use Android's Bluetooth library. Set the Glass device as a client to your phone app (which should work as the server). Set them up so that you can transfer the desired video to your Glass device. After completion of the transfer, you can then play the video on Glass.

Some classes you will need to read on to help you implement this:

  • BluetoothManager getSystemService and getAdapter
  • BluetoothAdapter listenUsingRfcommWithServiceRecord

You might also want to study the setup of the BluetoothChat application in Android Studio. You can check it out by selecting File -> Import Sample -> Connectivity -> Bluetooth Chat.

Koh
  • 1,570
  • 1
  • 8
  • 6
  • How can I Set the Glass device as a client to my phone app (which should work as the server) ? – DaChavoh Mar 06 '15 at 07:58
  • Please start [here](http://developer.android.com/guide/topics/connectivity/bluetooth.html#ConnectingAsAServer) on learning how to do that. – Koh Mar 06 '15 at 21:25