实际上我试图找出duration of video from URl
但它抛出空指针异常
try{
File file = new File("http://84.--.--.--:8--9/"+filename);
if ( file.toString().endsWith(".jpg")) {
//photo
} else if (file.toString().endsWith(".mp4")) {
//video
long mills = MediaPlayer.create(UploadFileService.this, Uri.parse(file.getAbsolutePath().toString())).getDuration();
Log.d("duration", "" + mills);
}
}catch(Exception e) {
e.printStackTrace();
}
}