Commit 2b7b9e1620bb9fdc3cd2c6508f9cf5e7567a44b5
1 parent
0de936c3
1:处理视频预览问题
Showing
2 changed files
with
8 additions
and
3 deletions
config.gradle
lib_media/src/main/java/com/cnlive/media/frame/view/RecordPreviewView.java
| @@ -11,6 +11,8 @@ import android.view.animation.OvershootInterpolator; | @@ -11,6 +11,8 @@ import android.view.animation.OvershootInterpolator; | ||
| 11 | import android.widget.FrameLayout; | 11 | import android.widget.FrameLayout; |
| 12 | import android.widget.RelativeLayout; | 12 | import android.widget.RelativeLayout; |
| 13 | 13 | ||
| 14 | +import androidx.core.content.FileProvider; | ||
| 15 | + | ||
| 14 | import com.bumptech.glide.Glide; | 16 | import com.bumptech.glide.Glide; |
| 15 | import com.bumptech.glide.load.engine.DiskCacheStrategy; | 17 | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| 16 | import com.bumptech.glide.request.RequestOptions; | 18 | import com.bumptech.glide.request.RequestOptions; |
| @@ -104,7 +106,9 @@ public class RecordPreviewView implements MvpView { | @@ -104,7 +106,9 @@ public class RecordPreviewView implements MvpView { | ||
| 104 | public void onSuccess(String path) { | 106 | public void onSuccess(String path) { |
| 105 | File file = new File(path); | 107 | File file = new File(path); |
| 106 | if (file != null && file.exists() && file.canRead() && file.canWrite()) { | 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 | media.setSelect(false); | 112 | media.setSelect(false); |
| 109 | media.setReturnUri(mActivity.mOptions.isReturnUri()); | 113 | media.setReturnUri(mActivity.mOptions.isReturnUri()); |
| 110 | if (mActivity.preBitmap != null && mActivity.preBitmap.getHeight() > 0 && mActivity.preBitmap.getWidth() > 0) { | 114 | if (mActivity.preBitmap != null && mActivity.preBitmap.getHeight() > 0 && mActivity.preBitmap.getWidth() > 0) { |
| @@ -145,7 +149,8 @@ public class RecordPreviewView implements MvpView { | @@ -145,7 +149,8 @@ public class RecordPreviewView implements MvpView { | ||
| 145 | public void saveVideo(RecordActivity mActivity) { | 149 | public void saveVideo(RecordActivity mActivity) { |
| 146 | if (mMediaFile == null || mActivity == null) return; | 150 | if (mMediaFile == null || mActivity == null) return; |
| 147 | File file = new File(mMediaFile.getFilepath()); | 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 | media.setImgWidth(mMediaFile.getVideoWidth()); | 154 | media.setImgWidth(mMediaFile.getVideoWidth()); |
| 150 | media.setImgHeight(mMediaFile.getVideoHeight()); | 155 | media.setImgHeight(mMediaFile.getVideoHeight()); |
| 151 | media.setSelect(false); | 156 | media.setSelect(false); |