How to get local video in Sketchware


Download Project
•••

Video in used code
•••
1.This code is for get video thumbnail
Bitmap bMap = ThumbnailUtils.createVideoThumbnail(file, android.provider.MediaStore.Video.Thumbnails.MICRO_KIND);
imageview1.setImageBitmap(bMap);

2.This code is for get video size
final java.io.File file1 = new java.io.File(file);
try{
long length = file1.length();
length = length/1024;
textview2.setText("File size : " + length +" KB");
}catch(Exception e){
showMessage("File not found : " + e.getMessage() + e);
}

3.This code is for get duration of video
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(getApplicationContext(), Uri.fromFile(file1));
String time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
long timeInMillisec = Long.parseLong(time );
retriever.release();
textview3.setText(String.valueOf(timeInMillisec/60000) + " min" + ", " + String.valueOf((timeInMillisec/1000)%60) + " s");

IT Ye Phyo (Information Technology)

Comments

Popular posts from this blog

APK install request permission