Commit 2b7b9e1620bb9fdc3cd2c6508f9cf5e7567a44b5

Authored by 吴奎庆
1 parent 0de936c3

1:处理视频预览问题

config.gradle
... ... @@ -21,7 +21,7 @@ ext {
21 21 //编译方式
22 22 debug : false,
23 23 //版本号
24   - version: "1.0.2.9",
  24 + version: "1.0.3.0",
25 25 //Lib库前缀
26 26 packeg : "com.cnlive.media",
27 27 //Lib库名称
... ...
lib_media/src/main/java/com/cnlive/media/frame/view/RecordPreviewView.java
... ... @@ -11,6 +11,8 @@ import android.view.animation.OvershootInterpolator;
11 11 import android.widget.FrameLayout;
12 12 import android.widget.RelativeLayout;
13 13  
  14 +import androidx.core.content.FileProvider;
  15 +
14 16 import com.bumptech.glide.Glide;
15 17 import com.bumptech.glide.load.engine.DiskCacheStrategy;
16 18 import com.bumptech.glide.request.RequestOptions;
... ... @@ -104,7 +106,9 @@ public class RecordPreviewView implements MvpView {
104 106 public void onSuccess(String path) {
105 107 File file = new File(path);
106 108 if (file != null && file.exists() && file.canRead() && file.canWrite()) {
107   - Media media = new Media(path, file.getName(), System.currentTimeMillis(), 1, file.length(), (int) System.currentTimeMillis(), file.getParent(), Uri.fromFile(file).toString());
  109 +
  110 + Uri uri = FileProvider.getUriForFile(mFragment.getActivity(), mFragment.getActivity().getApplicationContext().getPackageName() + ".fileprovider", file);
  111 + Media media = new Media(path, file.getName(), System.currentTimeMillis(), 1, file.length(), (int) System.currentTimeMillis(), file.getParent(), uri.toString());
108 112 media.setSelect(false);
109 113 media.setReturnUri(mActivity.mOptions.isReturnUri());
110 114 if (mActivity.preBitmap != null && mActivity.preBitmap.getHeight() > 0 && mActivity.preBitmap.getWidth() > 0) {
... ... @@ -145,7 +149,8 @@ public class RecordPreviewView implements MvpView {
145 149 public void saveVideo(RecordActivity mActivity) {
146 150 if (mMediaFile == null || mActivity == null) return;
147 151 File file = new File(mMediaFile.getFilepath());
148   - Media media = new Media(mMediaFile.getFilepath(), file.getName(), System.currentTimeMillis(), 3, file.length(), (int) System.currentTimeMillis(), file.getParent(), (int) mMediaFile.getDurationMs(), Uri.fromFile(file).toString());
  152 + Uri uri = FileProvider.getUriForFile(mFragment.getActivity(), mFragment.getActivity().getApplicationContext().getPackageName() + ".fileprovider", file);
  153 + Media media = new Media(mMediaFile.getFilepath(), file.getName(), System.currentTimeMillis(), 3, file.length(), (int) System.currentTimeMillis(), file.getParent(), (int) mMediaFile.getDurationMs(), uri.toString());
149 154 media.setImgWidth(mMediaFile.getVideoWidth());
150 155 media.setImgHeight(mMediaFile.getVideoHeight());
151 156 media.setSelect(false);
... ...