I want to show the thumbnail videos in an ImageView
. The videos are uploaded by the users and stored on a server. At the moment I have not set up any mechanism to store and upload the videos so I'm testing this with a sample video file that is accessed using http protocol. But, this post says that
ContentResolver.query returns null if the uri scheme is not of the form content://
Is my approach wrong? Is it possible to use this approach with http?
This is my test code:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.testlayout);
Uri uri = Uri.parse("http://download.wavetlan.com/SVV/Media/HTTP/BlackBerry.3gp");
Log.i("m",getRealPathFromURI(this, uri));
}
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
if (cursor == null)
{
Log.i("m","null");
return "";
}
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} finally {
if (cursor != null) {
cursor.close();
}
}
}