为什么通过fishwjy / Video压缩器压缩的视频要花费太多时间来加载或播放视频播放器?

时间:2019-03-01 10:43:45

标签: android

通过fishwjy / Video Compressor压缩视频后,压缩的视频要花费太多时间才能在视频播放器中加载或播放吗?请告诉我解决方案为什么会发生这种情况,fishwjy压缩器对于视频压缩来说太好了,但是压缩的视频花费了太多时间加载还是播放?

   if(requestCode == GALLERY_REQUEST){
      if (data.getData() != null) {
        try {
            selectedVideoPath = Util.getFilePath(mContext,data.getData());
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }

       KProgressHUD hud = KProgressHUD.create(mContext).setStyle(KProgressHUD.Style.SPIN_INDETERMINATE).setCancellable(true).setAnimationSpeed(2).setDimAmount(0.5f);


        String destPath = outputDir + File.separator + "out" + ".mp4";
        MediaPlayer mp = MediaPlayer.create(mContext, Uri.parse(selectedVideoPath));
        int duration = mp.getDuration();
        if ((duration / 1000) > 120) {
            Toast.makeText(mContext, "Sorry video should not more than 2 minutes!", Toast.LENGTH_SHORT).show();
        } else {
            VideoCompress.compressVideoLow(selectedVideoPath, destPath, new VideoCompress.CompressListener() {
                @Override
                public void onStart() {
                    hud.show();
                }

                @Override
                public void onSuccess() {
                    hud.dismiss();
                    UploadVideo(destPath);//uploading to server api call
                }

                @Override
                public void onFail() {
                    hud.dismiss();
                    Toast.makeText(mContext, "Compress failed", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onProgress(float percent) {

                }
            });
            Toast.makeText(getContext(), "Path : " + selectedVideoPath, Toast.LENGTH_SHORT).show();
        }
    }
}

0 个答案:

没有答案