I'm Using This Code For Playing Video During Downloading But When I Try To Play The Video_view Can't Play The Video
i'm using this code but when i try to play the video during download the video the video_view show me can't play the video private String videoPath='http://codechair.com/video/
Solution 1:
You have the following permission?
<uses-permissionandroid:name="android.permission.INTERNET" /><uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permissionandroid:name="android.permission.READ_EXTERNAL_STORAGE" />
Also you need to request permissions from the user:
publicstaticfinalintREQUEST_EXTERNAL_PERMISSION_CODE=666;
publicstaticfinal String[] PERMISSIONS_EXTERNAL_STORAGE = {
READ_EXTERNAL_STORAGE,
WRITE_EXTERNAL_STORAGE
};
publicbooleancheckExternalStoragePermission(Activity activity) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
returntrue;
}
intreadStoragePermissionState= ContextCompat.checkSelfPermission(activity, READ_EXTERNAL_STORAGE);
intwriteStoragePermissionState= ContextCompat.checkSelfPermission(activity, WRITE_EXTERNAL_STORAGE);
booleanexternalStoragePermissionGranted= readStoragePermissionState == PackageManager.PERMISSION_GRANTED &&
writeStoragePermissionState == PackageManager.PERMISSION_GRANTED;
if (!externalStoragePermissionGranted) {
requestPermissions(PERMISSIONS_EXTERNAL_STORAGE, REQUEST_EXTERNAL_PERMISSION_CODE);
}
return externalStoragePermissionGranted;
}
@OverridepublicvoidonRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNullint[] grantResults) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (requestCode == REQUEST_EXTERNAL_PERMISSION_CODE) {
if (checkExternalStoragePermission(this)) {
// Continue with your action after permission request succeed
}
}
}
}
And put in onCreate:
checkExternalStoragePermission(this);
Post a Comment for "I'm Using This Code For Playing Video During Downloading But When I Try To Play The Video_view Can't Play The Video"