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