简体   繁体   English

如何将手机中的视频检索到Google Glass中?

[英]How to retrieve videos from phone into Google glass?

I'm developing a Google Glass application which need to get videos from my phone and play it on my Google glass. 我正在开发Google Glass应用程序,该应用程序需要从手机中获取视频并在Google Glass上播放。 Can anyone please help me to retrieve videos from my phone into Google glass. 谁能帮助我从手机中检索视频到Google Glass中。

I managed to retrieve videos from Glass and play it, here my code : 我设法从Glass检索了视频并进行播放,这是我的代码:

   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 提前致谢

One option you have is to use Android's Bluetooth library. 您拥有的一种选择是使用Android的蓝牙库。 Set the Glass device as a client to your phone app (which should work as the server). 将Glass设备设置为手机应用程序的客户端(应作为服务器)。 Set them up so that you can transfer the desired video to your Glass device. 进行设置,以便将所需的视频传输到Glass设备。 After completion of the transfer, you can then play the video on Glass. 传输完成后,您可以在Glass上播放视频。

Some classes you will need to read on to help you implement this: 您需要继续阅读一些类以帮助您实现此目的:

  • BluetoothManager getSystemService and getAdapter BluetoothManager的getSystemService和getAdapter
  • BluetoothAdapter listenUsingRfcommWithServiceRecord 蓝牙适配器listenUsingRfcommWithServiceRecord

You might also want to study the setup of the BluetoothChat application in Android Studio. 您可能还需要研究Android Studio中BluetoothChat应用程序的设置。 You can check it out by selecting File -> Import Sample -> Connectivity -> Bluetooth Chat. 您可以通过选择文件->导入示例->连接性->蓝牙聊天来检出它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM