implementation 'com.iceteck.silicompressorr:silicompressor:2.2.1' 压缩的依赖
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data)
var sdf = SimpleDateFormat("dd-MM-yyyy"); var c = Calendar.getInstance(); var date = sdf.format(c.getTime());//视频 var path= SDCardUtils.getSDCardPath()+"jymj/map/video/"//+date+".mp4" /*try { }*/ object :Thread() { override fun run() { super.run() runOnUiThread(object :Runnable{ override fun run() { LoadingDialog.showDialogForLoading(activity) } }) var s = 0 var file=File(path) if (!file.exists()){ file.mkdirs() } try { /** * 视频压缩 * 第一个参数:视频源文件路径 * 第二个参数:压缩后视频保存的路径 */ var comPressPath = SiliCompressor.with(getActivity()).compressVideo(getRealPathFromURI(uri), path,1280, 720, 2000000);//Video file = File(comPressPath) } catch ( e: URISyntaxException) { s=1 e.printStackTrace(); }finally { if (s!=1){ runOnUiThread(object :Runnable{ override fun run() { LoadingDialog.showDialogForLoading(activity) upVideo(file) } }) } } } }.start();