Commit ec44c48eef21ef11781696fa3294b927500ef216
1 parent
176eea5f
处理七牛兼容性问题
Showing
49 changed files
with
775 additions
and
516 deletions
app/build.gradle
| @@ -4,7 +4,7 @@ android { | @@ -4,7 +4,7 @@ android { | ||
| 4 | compileSdkVersion 29 | 4 | compileSdkVersion 29 |
| 5 | 5 | ||
| 6 | defaultConfig { | 6 | defaultConfig { |
| 7 | - applicationId "com.cnlive.demo" | 7 | + applicationId "com.cnlive.strike.debug" |
| 8 | minSdkVersion 19 | 8 | minSdkVersion 19 |
| 9 | targetSdkVersion 29 | 9 | targetSdkVersion 29 |
| 10 | versionCode 1 | 10 | versionCode 1 |
app/src/main/AndroidManifest.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | - package="com.cnlive.demo"> | 3 | + package="com.cnlive.strike.debug"> |
| 4 | 4 | ||
| 5 | <application | 5 | <application |
| 6 | 6 | ||
| 7 | android:allowBackup="true" | 7 | android:allowBackup="true" |
| 8 | - android:name="com.cnlive.demo.MediaApplication" | 8 | + android:name=".MediaApplication" |
| 9 | android:icon="@mipmap/ic_launcher" | 9 | android:icon="@mipmap/ic_launcher" |
| 10 | android:label="@string/app_name" | 10 | android:label="@string/app_name" |
| 11 | android:roundIcon="@mipmap/ic_launcher_round" | 11 | android:roundIcon="@mipmap/ic_launcher_round" |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | android:theme="@style/AppTheme"> | 13 | android:theme="@style/AppTheme"> |
| 14 | <meta-data android:name="android.max_aspect" | 14 | <meta-data android:name="android.max_aspect" |
| 15 | android:value="ratio_float"/> | 15 | android:value="ratio_float"/> |
| 16 | - <activity android:name="com.cnlive.demo.MainActivity"> | 16 | + <activity android:name=".MainActivity"> |
| 17 | <intent-filter> | 17 | <intent-filter> |
| 18 | <action android:name="android.intent.action.MAIN" /> | 18 | <action android:name="android.intent.action.MAIN" /> |
| 19 | 19 |
app/src/main/java/com/cnlive/demo/MainActivity.java renamed to app/src/main/java/com/cnlive/strike/debug/MainActivity.java
| 1 | -package com.cnlive.demo; | 1 | +package com.cnlive.strike.debug; |
| 2 | 2 | ||
| 3 | import androidx.annotation.Nullable; | 3 | import androidx.annotation.Nullable; |
| 4 | import androidx.appcompat.app.AppCompatActivity; | 4 | import androidx.appcompat.app.AppCompatActivity; |
| @@ -8,11 +8,12 @@ import android.content.Intent; | @@ -8,11 +8,12 @@ import android.content.Intent; | ||
| 8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
| 9 | import android.view.View; | 9 | import android.view.View; |
| 10 | 10 | ||
| 11 | -import com.cnlive.demo.databinding.ActivityMainBinding; | ||
| 12 | import com.cnlive.media.ImagePicker; | 11 | import com.cnlive.media.ImagePicker; |
| 13 | import com.cnlive.media.PickerConfig; | 12 | import com.cnlive.media.PickerConfig; |
| 14 | -import com.cnlive.media.meidia.entity.Media; | 13 | +import com.cnlive.media.media.entity.Media; |
| 15 | import com.cnlive.media.utils.GlideCacheUtil; | 14 | import com.cnlive.media.utils.GlideCacheUtil; |
| 15 | +import com.cnlive.strike.debug.R; | ||
| 16 | +import com.cnlive.strike.debug.databinding.ActivityMainBinding; | ||
| 16 | 17 | ||
| 17 | import java.util.ArrayList; | 18 | import java.util.ArrayList; |
| 18 | 19 | ||
| @@ -50,13 +51,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe | @@ -50,13 +51,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe | ||
| 50 | //打开相册 | 51 | //打开相册 |
| 51 | new ImagePicker.Builder() | 52 | new ImagePicker.Builder() |
| 52 | .setSelectGif(false) | 53 | .setSelectGif(false) |
| 53 | - .needCamera(false) | 54 | + .needCamera(true) |
| 54 | .maxNum(9) | 55 | .maxNum(9) |
| 55 | .selectMode(PickerConfig.PICKER_IMAGE_VIDEO) | 56 | .selectMode(PickerConfig.PICKER_IMAGE_VIDEO) |
| 56 | .maxVideoSize(100 * 1024 * 1024) | 57 | .maxVideoSize(100 * 1024 * 1024) |
| 57 | .maxImageSize(1 * 1024 * 1024) | 58 | .maxImageSize(1 * 1024 * 1024) |
| 58 | .defaultSelectList(select) | 59 | .defaultSelectList(select) |
| 59 | - .doCrop(1, 1, 900, 900) | 60 | +// .doCrop(1, 1, 900, 900) |
| 60 | .builder() | 61 | .builder() |
| 61 | .start(this, PickerConfig.PICKER_IMAGE, PickerConfig.DEFAULT_RESULT_CODE); | 62 | .start(this, PickerConfig.PICKER_IMAGE, PickerConfig.DEFAULT_RESULT_CODE); |
| 62 | break; | 63 | break; |
app/src/main/java/com/cnlive/demo/MediaApplication.java renamed to app/src/main/java/com/cnlive/strike/debug/MediaApplication.java
| 1 | -package com.cnlive.demo; | 1 | +package com.cnlive.strike.debug; |
| 2 | 2 | ||
| 3 | import android.app.Application; | 3 | import android.app.Application; |
| 4 | 4 | ||
| 5 | import androidx.multidex.MultiDex; | 5 | import androidx.multidex.MultiDex; |
| 6 | 6 | ||
| 7 | +import com.cnlive.media.utils.QiniuVideoUtil; | ||
| 7 | 8 | ||
| 8 | -//import com.alibaba.android.arouter.launcher.ARouter; | ||
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | public class MediaApplication extends Application { | 11 | public class MediaApplication extends Application { |
| @@ -14,6 +14,6 @@ public class MediaApplication extends Application { | @@ -14,6 +14,6 @@ public class MediaApplication extends Application { | ||
| 14 | super.onCreate(); | 14 | super.onCreate(); |
| 15 | // ARouter.init(this); | 15 | // ARouter.init(this); |
| 16 | MultiDex.install(this); | 16 | MultiDex.install(this); |
| 17 | -// PLShortVideoEnv.init(this); | 17 | + QiniuVideoUtil.initVideo(this); |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
config.gradle
lib_media/src/main/java/com/cnlive/media/ImagePicker.java
| @@ -7,13 +7,13 @@ import android.content.Intent; | @@ -7,13 +7,13 @@ import android.content.Intent; | ||
| 7 | 7 | ||
| 8 | import com.cnlive.media.model.ImagePickerCropParams; | 8 | import com.cnlive.media.model.ImagePickerCropParams; |
| 9 | import com.cnlive.media.model.ImagePickerOptions; | 9 | import com.cnlive.media.model.ImagePickerOptions; |
| 10 | -import com.cnlive.media.meidia.entity.Media; | 10 | +import com.cnlive.media.media.entity.Media; |
| 11 | import com.cnlive.media.ui.activity.MediaActivity; | 11 | import com.cnlive.media.ui.activity.MediaActivity; |
| 12 | import com.cnlive.media.ui.activity.MediaPreviewActivity; | 12 | import com.cnlive.media.ui.activity.MediaPreviewActivity; |
| 13 | import com.cnlive.media.ui.activity.RecordActivity; | 13 | import com.cnlive.media.ui.activity.RecordActivity; |
| 14 | +import com.qiniu.pili.droid.shortvideo.PLShortVideoEnv; | ||
| 14 | 15 | ||
| 15 | import java.util.ArrayList; | 16 | import java.util.ArrayList; |
| 16 | -import java.util.List; | ||
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| 19 | * | 19 | * |
| @@ -125,6 +125,7 @@ public class ImagePicker { | @@ -125,6 +125,7 @@ public class ImagePicker { | ||
| 125 | mOptions = new ImagePickerOptions(); | 125 | mOptions = new ImagePickerOptions(); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | + | ||
| 128 | public Builder selectMode(int selectMode) { | 129 | public Builder selectMode(int selectMode) { |
| 129 | mOptions.setSelectMode(selectMode); | 130 | mOptions.setSelectMode(selectMode); |
| 130 | return this; | 131 | return this; |
lib_media/src/main/java/com/cnlive/media/frame/presenter/RecordFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.media.frame.presenter; | ||
| 2 | + | ||
| 3 | +import com.cnlive.media.frame.view.RecordFragmentView; | ||
| 4 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 作 者 : wkq | ||
| 8 | + * <p> | ||
| 9 | + * 时 间 : 2020/10/29 10:06 | ||
| 10 | + * <p> | ||
| 11 | + * 名 字 : RecordFragmentPresenter | ||
| 12 | + * <p> | ||
| 13 | + * 简 介 : | ||
| 14 | + */ | ||
| 15 | +public class RecordFragmentPresenter extends MvpBasePresenter<RecordFragmentView> { | ||
| 16 | + | ||
| 17 | +} |
lib_media/src/main/java/com/cnlive/media/frame/view/ImageCropView.java
| @@ -10,7 +10,7 @@ import android.text.TextUtils; | @@ -10,7 +10,7 @@ import android.text.TextUtils; | ||
| 10 | import com.cnlive.libs.base.util.AlertUtil; | 10 | import com.cnlive.libs.base.util.AlertUtil; |
| 11 | import com.cnlive.libs.base.util.FileUtils; | 11 | import com.cnlive.libs.base.util.FileUtils; |
| 12 | import com.cnlive.media.R; | 12 | import com.cnlive.media.R; |
| 13 | -import com.cnlive.media.meidia.entity.Media; | 13 | +import com.cnlive.media.media.entity.Media; |
| 14 | import com.cnlive.media.ui.activity.ImageCropActivity; | 14 | import com.cnlive.media.ui.activity.ImageCropActivity; |
| 15 | import com.cnlive.media.utils.AndroidQUtil; | 15 | import com.cnlive.media.utils.AndroidQUtil; |
| 16 | import com.cnlive.media.utils.observable.MeidaResultObservable; | 16 | import com.cnlive.media.utils.observable.MeidaResultObservable; |
lib_media/src/main/java/com/cnlive/media/frame/view/MediaFView.java
| @@ -4,7 +4,7 @@ import android.text.TextUtils; | @@ -4,7 +4,7 @@ import android.text.TextUtils; | ||
| 4 | import android.view.View; | 4 | import android.view.View; |
| 5 | 5 | ||
| 6 | import com.cnlive.libs.base.util.AlertUtil; | 6 | import com.cnlive.libs.base.util.AlertUtil; |
| 7 | -import com.cnlive.media.meidia.entity.Media; | 7 | +import com.cnlive.media.media.entity.Media; |
| 8 | import com.cnlive.media.ui.activity.VideoPlayerActivity; | 8 | import com.cnlive.media.ui.activity.VideoPlayerActivity; |
| 9 | import com.cnlive.media.ui.fragment.MediaFragment; | 9 | import com.cnlive.media.ui.fragment.MediaFragment; |
| 10 | import com.cnlive.media.ui.widget.large.ImageSource; | 10 | import com.cnlive.media.ui.widget.large.ImageSource; |
lib_media/src/main/java/com/cnlive/media/frame/view/MediaPickerFragmentView.java
| @@ -11,8 +11,8 @@ import com.bumptech.glide.Glide; | @@ -11,8 +11,8 @@ import com.bumptech.glide.Glide; | ||
| 11 | import com.cnlive.libs.base.util.AlertUtil; | 11 | import com.cnlive.libs.base.util.AlertUtil; |
| 12 | import com.cnlive.libs.base.util.DoublePressed; | 12 | import com.cnlive.libs.base.util.DoublePressed; |
| 13 | import com.cnlive.media.PickerConfig; | 13 | import com.cnlive.media.PickerConfig; |
| 14 | -import com.cnlive.media.meidia.entity.Folder; | ||
| 15 | -import com.cnlive.media.meidia.entity.Media; | 14 | +import com.cnlive.media.media.entity.Folder; |
| 15 | +import com.cnlive.media.media.entity.Media; | ||
| 16 | import com.cnlive.media.ui.activity.MediaActivity; | 16 | import com.cnlive.media.ui.activity.MediaActivity; |
| 17 | import com.cnlive.media.ui.fragment.MediaPickerFragment; | 17 | import com.cnlive.media.ui.fragment.MediaPickerFragment; |
| 18 | import com.cnlive.media.ui.adapter.MediaAdapter; | 18 | import com.cnlive.media.ui.adapter.MediaAdapter; |
lib_media/src/main/java/com/cnlive/media/frame/view/MediaPreviewViewView.java
| @@ -11,14 +11,12 @@ import androidx.viewpager2.widget.ViewPager2; | @@ -11,14 +11,12 @@ import androidx.viewpager2.widget.ViewPager2; | ||
| 11 | import com.cnlive.libs.base.util.AlertUtil; | 11 | import com.cnlive.libs.base.util.AlertUtil; |
| 12 | import com.cnlive.libs.base.util.StatusBarUtil2; | 12 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 13 | import com.cnlive.media.PickerConfig; | 13 | import com.cnlive.media.PickerConfig; |
| 14 | -import com.cnlive.media.meidia.entity.Media; | 14 | +import com.cnlive.media.media.entity.Media; |
| 15 | import com.cnlive.media.ui.activity.MediaPreviewActivity; | 15 | import com.cnlive.media.ui.activity.MediaPreviewActivity; |
| 16 | import com.cnlive.media.ui.adapter.MediaPreviewAdapter; | 16 | import com.cnlive.media.ui.adapter.MediaPreviewAdapter; |
| 17 | import com.cnlive.media.R; | 17 | import com.cnlive.media.R; |
| 18 | import com.hannesdorfmann.mosby3.mvp.MvpView; | 18 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 19 | 19 | ||
| 20 | -import java.util.ArrayList; | ||
| 21 | - | ||
| 22 | /** | 20 | /** |
| 23 | * 作 者 : wkq | 21 | * 作 者 : wkq |
| 24 | * <p> | 22 | * <p> |
lib_media/src/main/java/com/cnlive/media/frame/view/MediaView.java
| @@ -24,8 +24,8 @@ import androidx.recyclerview.widget.RecyclerView; | @@ -24,8 +24,8 @@ import androidx.recyclerview.widget.RecyclerView; | ||
| 24 | import com.cnlive.libs.base.util.AlertUtil; | 24 | import com.cnlive.libs.base.util.AlertUtil; |
| 25 | import com.cnlive.libs.base.util.StatusBarUtil2; | 25 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 26 | import com.cnlive.media.PickerConfig; | 26 | import com.cnlive.media.PickerConfig; |
| 27 | -import com.cnlive.media.meidia.entity.Folder; | ||
| 28 | -import com.cnlive.media.meidia.entity.Media; | 27 | +import com.cnlive.media.media.entity.Folder; |
| 28 | +import com.cnlive.media.media.entity.Media; | ||
| 29 | import com.cnlive.media.ui.activity.ImageCropActivity; | 29 | import com.cnlive.media.ui.activity.ImageCropActivity; |
| 30 | import com.cnlive.media.ui.activity.MediaActivity; | 30 | import com.cnlive.media.ui.activity.MediaActivity; |
| 31 | import com.cnlive.media.ui.activity.RecordActivity; | 31 | import com.cnlive.media.ui.activity.RecordActivity; |
| @@ -103,7 +103,7 @@ public class MediaView implements MvpView { | @@ -103,7 +103,7 @@ public class MediaView implements MvpView { | ||
| 103 | 103 | ||
| 104 | private void initState() { | 104 | private void initState() { |
| 105 | StatusBarUtil2.setColor(mActivity, mActivity.getResources().getColor(R.color.status_bar_color), 0); | 105 | StatusBarUtil2.setColor(mActivity, mActivity.getResources().getColor(R.color.status_bar_color), 0); |
| 106 | - //初始化七牛录制 | 106 | +// //初始化七牛录制 |
| 107 | PLShortVideoEnv.init(mActivity.getApplicationContext()); | 107 | PLShortVideoEnv.init(mActivity.getApplicationContext()); |
| 108 | MediaAddObservable.getInstance().addObserver(mActivity); | 108 | MediaAddObservable.getInstance().addObserver(mActivity); |
| 109 | MeidaResultObservable.getInstance().addObserver(mActivity); | 109 | MeidaResultObservable.getInstance().addObserver(mActivity); |
lib_media/src/main/java/com/cnlive/media/frame/view/RecordFragmentView.java
0 → 100644
| 1 | +package com.cnlive.media.frame.view; | ||
| 2 | + | ||
| 3 | +import android.animation.Animator; | ||
| 4 | +import android.animation.AnimatorSet; | ||
| 5 | +import android.animation.ObjectAnimator; | ||
| 6 | +import android.os.Environment; | ||
| 7 | +import android.text.TextUtils; | ||
| 8 | +import android.util.Log; | ||
| 9 | +import android.view.MotionEvent; | ||
| 10 | +import android.view.View; | ||
| 11 | +import android.view.animation.OvershootInterpolator; | ||
| 12 | + | ||
| 13 | +import androidx.activity.OnBackPressedCallback; | ||
| 14 | + | ||
| 15 | +import com.cnlive.libs.base.util.AlertUtil; | ||
| 16 | +import com.cnlive.media.PickerConfig; | ||
| 17 | +import com.cnlive.media.ui.activity.MediaActivity; | ||
| 18 | +import com.cnlive.media.ui.activity.RecordActivity; | ||
| 19 | +import com.cnlive.media.ui.fragment.RecordFragment; | ||
| 20 | +import com.cnlive.media.utils.AndroidQUtil; | ||
| 21 | +import com.cnlive.media.utils.ScreenUtils; | ||
| 22 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 23 | +import com.qiniu.pili.droid.shortvideo.PLAudioEncodeSetting; | ||
| 24 | +import com.qiniu.pili.droid.shortvideo.PLCameraSetting; | ||
| 25 | +import com.qiniu.pili.droid.shortvideo.PLDisplayMode; | ||
| 26 | +import com.qiniu.pili.droid.shortvideo.PLMicrophoneSetting; | ||
| 27 | +import com.qiniu.pili.droid.shortvideo.PLRecordSetting; | ||
| 28 | +import com.qiniu.pili.droid.shortvideo.PLRecordStateListener; | ||
| 29 | +import com.qiniu.pili.droid.shortvideo.PLShortVideoRecorder; | ||
| 30 | +import com.qiniu.pili.droid.shortvideo.PLVideoEncodeSetting; | ||
| 31 | + | ||
| 32 | +import java.io.File; | ||
| 33 | + | ||
| 34 | +/** | ||
| 35 | + * 作 者 : wkq | ||
| 36 | + * <p> | ||
| 37 | + * 时 间 : 2020/10/29 10:05 | ||
| 38 | + * <p> | ||
| 39 | + * 名 字 : RecordFragmentView | ||
| 40 | + * <p> | ||
| 41 | + * 简 介 : | ||
| 42 | + */ | ||
| 43 | +public class RecordFragmentView implements MvpView, PLRecordStateListener { | ||
| 44 | + | ||
| 45 | + RecordFragment mFragment; | ||
| 46 | + private PLRecordSetting recordSetting; | ||
| 47 | + private PLAudioEncodeSetting audioEncodeSetting; | ||
| 48 | + private PLMicrophoneSetting microphoneSetting; | ||
| 49 | + private PLVideoEncodeSetting videoEncodeSetting; | ||
| 50 | + private PLCameraSetting cameraSetting; | ||
| 51 | + String videoCaceDirPath; | ||
| 52 | + | ||
| 53 | + public RecordFragmentView(RecordFragment mFragment) { | ||
| 54 | + this.mFragment = mFragment; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public RecordActivity getActivity() { | ||
| 58 | + return (RecordActivity) mFragment.getActivity(); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public void initView() { | ||
| 62 | + // 摄像头采集选项 | ||
| 63 | + if (mFragment.plShortVideoRecorder == null) | ||
| 64 | + mFragment.plShortVideoRecorder = new PLShortVideoRecorder(); | ||
| 65 | + if (cameraSetting == null) | ||
| 66 | + cameraSetting = new PLCameraSetting(); | ||
| 67 | + //设置摄像头 | ||
| 68 | + cameraSetting.setCameraId(chooseCameraFacingId()); | ||
| 69 | + cameraSetting.setCameraPreviewSizeRatio(PLCameraSetting.CAMERA_PREVIEW_SIZE_RATIO.RATIO_16_9); | ||
| 70 | + cameraSetting.setCameraPreviewSizeLevel(PLCameraSetting.CAMERA_PREVIEW_SIZE_LEVEL.PREVIEW_SIZE_LEVEL_720P); | ||
| 71 | + // 麦克风采集选项 | ||
| 72 | + if (microphoneSetting == null) | ||
| 73 | + microphoneSetting = new PLMicrophoneSetting(); | ||
| 74 | + // 视频编码选项 | ||
| 75 | + videoEncodeSetting = new PLVideoEncodeSetting(mFragment.getActivity()); | ||
| 76 | + videoEncodeSetting.setEncodingSizeLevel(PLVideoEncodeSetting.VIDEO_ENCODING_SIZE_LEVEL.VIDEO_ENCODING_SIZE_LEVEL_720P_3); // 480x480 | ||
| 77 | + videoEncodeSetting.setEncodingBitrate(4000 * 1024); // 1000kbps | ||
| 78 | + videoEncodeSetting.setHWCodecEnabled(true); // true:硬编 false:软编 | ||
| 79 | + // 音频编码选项 | ||
| 80 | + audioEncodeSetting = new PLAudioEncodeSetting(); | ||
| 81 | + audioEncodeSetting.setHWCodecEnabled(true); // true:硬编 false:软编 | ||
| 82 | + // 美颜选项 | ||
| 83 | + // 录制选项 | ||
| 84 | + recordSetting = new PLRecordSetting(); | ||
| 85 | +// 最大录制时常 | ||
| 86 | + recordSetting.setMaxRecordDuration(getActivity() .mOptions.getMaxTime()); | ||
| 87 | + recordSetting.setRecordSpeedVariable(true); | ||
| 88 | + recordSetting.setDisplayMode(PLDisplayMode.FULL); | ||
| 89 | + | ||
| 90 | + | ||
| 91 | + if (TextUtils.isEmpty(getActivity() .mOptions.getCachePath())) { | ||
| 92 | + if (AndroidQUtil.isAndroidQ()) { | ||
| 93 | + videoCaceDirPath = getActivity() .getExternalFilesDir("").getPath() + File.separator + "MediaPickerVideo"; | ||
| 94 | + } else { | ||
| 95 | + videoCaceDirPath = Environment.getExternalStorageDirectory().getPath() + File.separator + "MediaPickerVideo"; | ||
| 96 | + } | ||
| 97 | + } else { | ||
| 98 | + if (AndroidQUtil.isAndroidQ()) { | ||
| 99 | + videoCaceDirPath = mFragment.getActivity().getExternalFilesDir("").getPath() + File.separator + "MediaPickerVideo"; | ||
| 100 | + } else { | ||
| 101 | + videoCaceDirPath = getActivity() .mOptions.getCachePath(); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + getActivity() .mOptions.setCachePath(videoCaceDirPath); | ||
| 105 | + recordSetting.setVideoCacheDir(videoCaceDirPath); | ||
| 106 | + | ||
| 107 | + getActivity() .videoPath = getActivity() .mOptions.getCachePath() + System.currentTimeMillis() + ".mp4"; | ||
| 108 | + recordSetting.setVideoFilepath(getActivity() .videoPath); | ||
| 109 | + mFragment.binding.rcControl.setFlashState(false); | ||
| 110 | + mFragment.binding.rcControl.setMaxTime(getActivity() .mOptions.getMaxTime()); | ||
| 111 | + | ||
| 112 | + //设置闪光灯 | ||
| 113 | + | ||
| 114 | + // 设置录制速度 (默认为 1.0) | ||
| 115 | + mFragment.plShortVideoRecorder.setRecordStateListener(this); | ||
| 116 | + | ||
| 117 | + mFragment.plShortVideoRecorder.prepare(mFragment.binding.gSf, cameraSetting, microphoneSetting, videoEncodeSetting, audioEncodeSetting, null, recordSetting); | ||
| 118 | + //处理手动对焦事件 | ||
| 119 | + mFragment.binding.gSf.requestRender(); | ||
| 120 | + mFragment.binding.gSf.setOnTouchListener(new View.OnTouchListener() { | ||
| 121 | + @Override | ||
| 122 | + public boolean onTouch(View v, MotionEvent event) { | ||
| 123 | + if (event.getAction() == MotionEvent.ACTION_UP) { | ||
| 124 | + moveFocus(event.getRawX(), event.getRawY()); | ||
| 125 | + } | ||
| 126 | + return true; | ||
| 127 | + } | ||
| 128 | + }); | ||
| 129 | + //如果是裁剪类型只支持拍照 | ||
| 130 | + if (getActivity() .isJumpCamera && getActivity() .mOptions.getJumpCameraMode() >= 0) { | ||
| 131 | + mFragment.binding.rcControl.setRecordType(getActivity() .mOptions.getJumpCameraMode()); | ||
| 132 | + } else { | ||
| 133 | + if (getActivity() .mOptions.isNeedCrop()) { | ||
| 134 | + mFragment.binding.rcControl.setRecordType(PickerConfig.CAMERA_MODE_PIC); | ||
| 135 | + } else { | ||
| 136 | + mFragment.binding.rcControl.setRecordType(PickerConfig.CAMERA_MODE_ALL); | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + /** | ||
| 142 | + * 选择相机 | ||
| 143 | + * @return | ||
| 144 | + */ | ||
| 145 | + private PLCameraSetting.CAMERA_FACING_ID chooseCameraFacingId() { | ||
| 146 | + if (PLCameraSetting.hasCameraFacing(PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD)) { | ||
| 147 | + return PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD; | ||
| 148 | + } else if (PLCameraSetting.hasCameraFacing(PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK)) { | ||
| 149 | + return PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK; | ||
| 150 | + } else { | ||
| 151 | + return PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT; | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + /** | ||
| 156 | + * 设置闪光灯 | ||
| 157 | + * @param isFlashingState | ||
| 158 | + */ | ||
| 159 | + public void processFlash(boolean isFlashingState) { | ||
| 160 | + mFragment.binding.rcControl.setFlashState(isFlashingState); | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * 异常 | ||
| 165 | + * @param message | ||
| 166 | + */ | ||
| 167 | + public void showMesage(String message) { | ||
| 168 | + | ||
| 169 | + if (TextUtils.isEmpty(message) || mFragment == null || mFragment.getActivity().isFinishing()) | ||
| 170 | + return; | ||
| 171 | + mFragment.getActivity().runOnUiThread(new Runnable() { | ||
| 172 | + @Override | ||
| 173 | + public void run() { | ||
| 174 | + AlertUtil.showDeftToast(mFragment.getActivity(), message); | ||
| 175 | + } | ||
| 176 | + }); | ||
| 177 | + | ||
| 178 | + | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + //移动对焦的动画 | ||
| 182 | + public void moveFocus(float x, float y) { | ||
| 183 | + | ||
| 184 | + mFragment.plShortVideoRecorder.manualFocus(80, 80, (int) x, (int) y); | ||
| 185 | + //缩小 | ||
| 186 | + float transX = x - ScreenUtils.getScreenWidth(getActivity()) / 2; | ||
| 187 | + | ||
| 188 | + float transY = y - ScreenUtils.getScreenHeight(getActivity()) / 2; | ||
| 189 | + ObjectAnimator translationX = ObjectAnimator.ofFloat(mFragment.binding.fv, "translationX", 0, transX); | ||
| 190 | + ObjectAnimator translationY = ObjectAnimator.ofFloat(mFragment.binding.fv, "translationY", 0, transY); | ||
| 191 | + AnimatorSet animSet = new AnimatorSet(); | ||
| 192 | + animSet.play(translationX).with(translationY); | ||
| 193 | + animSet.start(); | ||
| 194 | + animSet.addListener(new Animator.AnimatorListener() { | ||
| 195 | + @Override | ||
| 196 | + public void onAnimationStart(Animator animation) { | ||
| 197 | + | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + @Override | ||
| 201 | + public void onAnimationEnd(Animator animation) { | ||
| 202 | + mFragment.binding.fv.setVisibility(View.VISIBLE); | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + @Override | ||
| 206 | + public void onAnimationCancel(Animator animation) { | ||
| 207 | + | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + @Override | ||
| 211 | + public void onAnimationRepeat(Animator animation) { | ||
| 212 | + | ||
| 213 | + } | ||
| 214 | + }); | ||
| 215 | + ObjectAnimator scaleX = ObjectAnimator.ofFloat(mFragment.binding.fv, "scaleX", 1, 0.6f); | ||
| 216 | + ObjectAnimator scaleY = ObjectAnimator.ofFloat(mFragment.binding.fv, "scaleY", 1, 0.6f); | ||
| 217 | + | ||
| 218 | + AnimatorSet animSet2 = new AnimatorSet(); | ||
| 219 | + animSet2.play(scaleY).with(scaleX); | ||
| 220 | + animSet2.setInterpolator(new OvershootInterpolator()); | ||
| 221 | + animSet2.setDuration(800); | ||
| 222 | + animSet2.start(); | ||
| 223 | + animSet2.addListener(new Animator.AnimatorListener() { | ||
| 224 | + | ||
| 225 | + @Override | ||
| 226 | + public void onAnimationStart(Animator animation) { | ||
| 227 | + | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + @Override | ||
| 231 | + public void onAnimationEnd(Animator animation) { | ||
| 232 | + mFragment.binding.fv.setVisibility(View.GONE); | ||
| 233 | + } | ||
| 234 | + | ||
| 235 | + @Override | ||
| 236 | + public void onAnimationCancel(Animator animation) { | ||
| 237 | + | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + @Override | ||
| 241 | + public void onAnimationRepeat(Animator animation) { | ||
| 242 | + | ||
| 243 | + } | ||
| 244 | + }); | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + | ||
| 248 | + | ||
| 249 | + @Override | ||
| 250 | + public void onReady() { | ||
| 251 | + //设置闪光灯 | ||
| 252 | + mFragment.isReady = true; | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + @Override | ||
| 256 | + public void onError(int i) { | ||
| 257 | + showMesage("相机初始化异常"); | ||
| 258 | + mFragment.isReady = false; | ||
| 259 | + mFragment.isRecordIng = false; | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + @Override | ||
| 263 | + public void onDurationTooShort() { | ||
| 264 | + Log.e("", ""); | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + @Override | ||
| 268 | + public void onRecordStarted() { | ||
| 269 | + Log.e("", ""); | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + @Override | ||
| 273 | + public void onSectionRecording(long l, long l1, int i) { | ||
| 274 | + Log.e("", ""); | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + @Override | ||
| 278 | + public void onRecordStopped() { | ||
| 279 | + Log.e("", ""); | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + @Override | ||
| 283 | + public void onSectionIncreased(long l, long l1, int i) { | ||
| 284 | + Log.e("", ""); | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + @Override | ||
| 288 | + public void onSectionDecreased(long l, long l1, int i) { | ||
| 289 | + Log.e("", ""); | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + @Override | ||
| 293 | + public void onRecordCompleted() { | ||
| 294 | + mFragment.isReady = false; | ||
| 295 | + mFragment.isRecordIng = false; | ||
| 296 | + } | ||
| 297 | +} |
lib_media/src/main/java/com/cnlive/media/frame/view/RecordPreviewView.java
| @@ -13,7 +13,7 @@ import android.widget.RelativeLayout; | @@ -13,7 +13,7 @@ import android.widget.RelativeLayout; | ||
| 13 | 13 | ||
| 14 | import com.cnlive.libs.base.util.AlertUtil; | 14 | import com.cnlive.libs.base.util.AlertUtil; |
| 15 | import com.cnlive.media.PickerConfig; | 15 | import com.cnlive.media.PickerConfig; |
| 16 | -import com.cnlive.media.meidia.entity.Media; | 16 | +import com.cnlive.media.media.entity.Media; |
| 17 | import com.cnlive.media.ui.activity.ImageCropActivity; | 17 | import com.cnlive.media.ui.activity.ImageCropActivity; |
| 18 | import com.cnlive.media.ui.activity.RecordActivity; | 18 | import com.cnlive.media.ui.activity.RecordActivity; |
| 19 | import com.cnlive.media.ui.fragment.RecordPreviewFragment; | 19 | import com.cnlive.media.ui.fragment.RecordPreviewFragment; |
lib_media/src/main/java/com/cnlive/media/frame/view/RecordView.java
| 1 | package com.cnlive.media.frame.view; | 1 | package com.cnlive.media.frame.view; |
| 2 | 2 | ||
| 3 | -import android.animation.Animator; | ||
| 4 | -import android.animation.AnimatorSet; | ||
| 5 | -import android.animation.ObjectAnimator; | ||
| 6 | import android.app.Dialog; | 3 | import android.app.Dialog; |
| 7 | import android.content.pm.ActivityInfo; | 4 | import android.content.pm.ActivityInfo; |
| 8 | -import android.graphics.Bitmap; | ||
| 9 | import android.os.Build; | 5 | import android.os.Build; |
| 10 | -import android.os.Environment; | ||
| 11 | import android.text.TextUtils; | 6 | import android.text.TextUtils; |
| 12 | -import android.util.Log; | ||
| 13 | -import android.view.MotionEvent; | ||
| 14 | import android.view.View; | 7 | import android.view.View; |
| 15 | -import android.view.animation.OvershootInterpolator; | 8 | +import android.view.WindowManager; |
| 16 | 9 | ||
| 17 | import androidx.activity.OnBackPressedCallback; | 10 | import androidx.activity.OnBackPressedCallback; |
| 18 | import androidx.core.app.ActivityCompat; | 11 | import androidx.core.app.ActivityCompat; |
| 19 | import androidx.fragment.app.Fragment; | 12 | import androidx.fragment.app.Fragment; |
| 20 | 13 | ||
| 21 | import com.cnlive.libs.base.util.AlertUtil; | 14 | import com.cnlive.libs.base.util.AlertUtil; |
| 22 | -import com.cnlive.media.PickerConfig; | 15 | +import com.cnlive.media.R; |
| 23 | import com.cnlive.media.ui.activity.RecordActivity; | 16 | import com.cnlive.media.ui.activity.RecordActivity; |
| 17 | +import com.cnlive.media.ui.fragment.RecordFragment; | ||
| 24 | import com.cnlive.media.ui.fragment.RecordPreviewFragment; | 18 | import com.cnlive.media.ui.fragment.RecordPreviewFragment; |
| 25 | import com.cnlive.media.utils.AlertDialogUtils; | 19 | import com.cnlive.media.utils.AlertDialogUtils; |
| 26 | -import com.cnlive.media.utils.AndroidQUtil; | ||
| 27 | import com.cnlive.media.utils.PermissionChecker; | 20 | import com.cnlive.media.utils.PermissionChecker; |
| 28 | -import com.cnlive.media.utils.ScreenUtils; | ||
| 29 | -import com.cnlive.media.R; | ||
| 30 | import com.hannesdorfmann.mosby3.mvp.MvpView; | 21 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 31 | -import com.qiniu.pili.droid.shortvideo.PLAudioEncodeSetting; | ||
| 32 | -import com.qiniu.pili.droid.shortvideo.PLCameraSetting; | ||
| 33 | -import com.qiniu.pili.droid.shortvideo.PLDisplayMode; | ||
| 34 | -import com.qiniu.pili.droid.shortvideo.PLErrorCode; | ||
| 35 | -import com.qiniu.pili.droid.shortvideo.PLMicrophoneSetting; | ||
| 36 | -import com.qiniu.pili.droid.shortvideo.PLRecordSetting; | ||
| 37 | -import com.qiniu.pili.droid.shortvideo.PLRecordStateListener; | ||
| 38 | -import com.qiniu.pili.droid.shortvideo.PLShortVideoRecorder; | ||
| 39 | -import com.qiniu.pili.droid.shortvideo.PLVideoEncodeSetting; | ||
| 40 | - | ||
| 41 | -import java.io.File; | ||
| 42 | 22 | ||
| 43 | /** | 23 | /** |
| 44 | * 作 者 : wkq | 24 | * 作 者 : wkq |
| @@ -49,28 +29,22 @@ import java.io.File; | @@ -49,28 +29,22 @@ import java.io.File; | ||
| 49 | * <p> | 29 | * <p> |
| 50 | * 简 介 : | 30 | * 简 介 : |
| 51 | */ | 31 | */ |
| 52 | -public class RecordView implements MvpView, PLRecordStateListener { | 32 | +public class RecordView implements MvpView { |
| 53 | 33 | ||
| 54 | RecordActivity mActivity; | 34 | RecordActivity mActivity; |
| 55 | - private PLRecordSetting recordSetting; | ||
| 56 | - private PLAudioEncodeSetting audioEncodeSetting; | ||
| 57 | - private PLMicrophoneSetting microphoneSetting; | ||
| 58 | - private PLVideoEncodeSetting videoEncodeSetting; | ||
| 59 | - private PLCameraSetting cameraSetting; | ||
| 60 | - String videoCaceDirPath; | ||
| 61 | 35 | ||
| 62 | public RecordView(RecordActivity mActivity) { | 36 | public RecordView(RecordActivity mActivity) { |
| 63 | this.mActivity = mActivity; | 37 | this.mActivity = mActivity; |
| 64 | } | 38 | } |
| 65 | 39 | ||
| 66 | public void initView() { | 40 | public void initView() { |
| 41 | + processFullScreen(); | ||
| 67 | //处理fragment 回调 | 42 | //处理fragment 回调 |
| 68 | mActivity.getOnBackPressedDispatcher().addCallback(mActivity, new OnBackPressedCallback(true) { | 43 | mActivity.getOnBackPressedDispatcher().addCallback(mActivity, new OnBackPressedCallback(true) { |
| 69 | @Override | 44 | @Override |
| 70 | public void handleOnBackPressed() { | 45 | public void handleOnBackPressed() { |
| 71 | Fragment currentFragment = mActivity.getSupportFragmentManager().findFragmentById(R.id.pre_frame); | 46 | Fragment currentFragment = mActivity.getSupportFragmentManager().findFragmentById(R.id.pre_frame); |
| 72 | if (currentFragment instanceof RecordPreviewFragment) { | 47 | if (currentFragment instanceof RecordPreviewFragment) { |
| 73 | - showControl(); | ||
| 74 | mActivity.getSupportFragmentManager().popBackStack(); | 48 | mActivity.getSupportFragmentManager().popBackStack(); |
| 75 | } else { | 49 | } else { |
| 76 | mActivity.finish(); | 50 | mActivity.finish(); |
| @@ -78,6 +52,7 @@ public class RecordView implements MvpView, PLRecordStateListener { | @@ -78,6 +52,7 @@ public class RecordView implements MvpView, PLRecordStateListener { | ||
| 78 | } | 52 | } |
| 79 | }); | 53 | }); |
| 80 | 54 | ||
| 55 | + | ||
| 81 | if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { | 56 | if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { |
| 82 | mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | 57 | mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| 83 | } | 58 | } |
| @@ -90,242 +65,27 @@ public class RecordView implements MvpView, PLRecordStateListener { | @@ -90,242 +65,27 @@ public class RecordView implements MvpView, PLRecordStateListener { | ||
| 90 | boolean hasPermissions = mActivity.getPresenter() | 65 | boolean hasPermissions = mActivity.getPresenter() |
| 91 | .checkPermissions(mActivity, mActivity.permissionsRecord, mActivity.PERMISISSION_CODE_ASK, true); | 66 | .checkPermissions(mActivity, mActivity.permissionsRecord, mActivity.PERMISISSION_CODE_ASK, true); |
| 92 | if (hasPermissions) { | 67 | if (hasPermissions) { |
| 93 | - initQNRecord(); | ||
| 94 | - } | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - public void showControl() { | ||
| 98 | - | ||
| 99 | - mActivity.runOnUiThread(new Runnable() { | ||
| 100 | - @Override | ||
| 101 | - public void run() { | ||
| 102 | - mActivity.binding.gSf.setVisibility(View.VISIBLE); | ||
| 103 | - mActivity.binding.rcControl.setVisibility(View.VISIBLE); | ||
| 104 | - mActivity.binding.preFrame.setVisibility(View.GONE); | ||
| 105 | - } | ||
| 106 | - }); | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - public void showPre() { | ||
| 110 | - mActivity.runOnUiThread(new Runnable() { | ||
| 111 | - @Override | ||
| 112 | - public void run() { | ||
| 113 | - mActivity.binding.gSf.setVisibility(View.GONE); | ||
| 114 | - mActivity.binding.rcControl.setVisibility(View.GONE); | ||
| 115 | - mActivity.binding.preFrame.setVisibility(View.VISIBLE); | ||
| 116 | - } | ||
| 117 | - }); | ||
| 118 | - | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - private PLCameraSetting.CAMERA_FACING_ID chooseCameraFacingId() { | ||
| 122 | - if (PLCameraSetting.hasCameraFacing(PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD)) { | ||
| 123 | - return PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD; | ||
| 124 | - } else if (PLCameraSetting.hasCameraFacing(PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK)) { | ||
| 125 | - return PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK; | ||
| 126 | - } else { | ||
| 127 | - return PLCameraSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT; | 68 | + mActivity.getSupportFragmentManager().beginTransaction().replace(R.id.pre_frame, RecordFragment.newInstance()).addToBackStack("").commit(); |
| 128 | } | 69 | } |
| 129 | - } | ||
| 130 | - | ||
| 131 | - @Override | ||
| 132 | - public void onReady() { | ||
| 133 | - //设置闪光灯 | ||
| 134 | - mActivity.isReady = true; | ||
| 135 | - } | ||
| 136 | 70 | ||
| 137 | - @Override | ||
| 138 | - public void onError(int i) { | ||
| 139 | - processError(i); | ||
| 140 | - mActivity.isReady=false; | ||
| 141 | - mActivity.isRecordIng=false; | ||
| 142 | } | 71 | } |
| 143 | - | ||
| 144 | - @Override | ||
| 145 | - public void onDurationTooShort() { | ||
| 146 | - Log.e("", ""); | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - @Override | ||
| 150 | - public void onRecordStarted() { | ||
| 151 | - Log.e("", ""); | ||
| 152 | - } | ||
| 153 | - | ||
| 154 | - @Override | ||
| 155 | - public void onSectionRecording(long l, long l1, int i) { | ||
| 156 | - Log.e("", ""); | ||
| 157 | - } | ||
| 158 | - | ||
| 159 | - @Override | ||
| 160 | - public void onRecordStopped() { | ||
| 161 | - Log.e("", ""); | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - @Override | ||
| 165 | - public void onSectionIncreased(long l, long l1, int i) { | ||
| 166 | - Log.e("", ""); | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - @Override | ||
| 170 | - public void onSectionDecreased(long l, long l1, int i) { | ||
| 171 | - Log.e("", ""); | ||
| 172 | - } | ||
| 173 | - | ||
| 174 | - @Override | ||
| 175 | - public void onRecordCompleted() { | ||
| 176 | - mActivity.isReady=false; | ||
| 177 | - mActivity.isRecordIng=false; | ||
| 178 | - } | ||
| 179 | - | ||
| 180 | /** | 72 | /** |
| 181 | - * 初始化七牛录制 | 73 | + * 处理刘海屏全屏问题 |
| 182 | */ | 74 | */ |
| 183 | - private void initQNRecord() { | ||
| 184 | - // 摄像头采集选项 | ||
| 185 | - if (mActivity.plShortVideoRecorder == null) | ||
| 186 | - mActivity.plShortVideoRecorder = new PLShortVideoRecorder(); | ||
| 187 | - if (cameraSetting == null) | ||
| 188 | - cameraSetting = new PLCameraSetting(); | ||
| 189 | - //设置摄像头 | ||
| 190 | - cameraSetting.setCameraId(chooseCameraFacingId()); | ||
| 191 | - cameraSetting.setCameraPreviewSizeRatio(PLCameraSetting.CAMERA_PREVIEW_SIZE_RATIO.RATIO_16_9); | ||
| 192 | - cameraSetting.setCameraPreviewSizeLevel(PLCameraSetting.CAMERA_PREVIEW_SIZE_LEVEL.PREVIEW_SIZE_LEVEL_720P); | ||
| 193 | - // 麦克风采集选项 | ||
| 194 | - if (microphoneSetting == null) | ||
| 195 | - microphoneSetting = new PLMicrophoneSetting(); | ||
| 196 | - // 视频编码选项 | ||
| 197 | - videoEncodeSetting = new PLVideoEncodeSetting(mActivity); | ||
| 198 | - videoEncodeSetting.setEncodingSizeLevel(PLVideoEncodeSetting.VIDEO_ENCODING_SIZE_LEVEL.VIDEO_ENCODING_SIZE_LEVEL_720P_3); // 480x480 | ||
| 199 | - videoEncodeSetting.setEncodingBitrate( 4000 * 1024); // 1000kbps | ||
| 200 | - videoEncodeSetting.setHWCodecEnabled(true); // true:硬编 false:软编 | ||
| 201 | - // 音频编码选项 | ||
| 202 | - audioEncodeSetting = new PLAudioEncodeSetting(); | ||
| 203 | - audioEncodeSetting.setHWCodecEnabled(true); // true:硬编 false:软编 | ||
| 204 | - // 美颜选项 | ||
| 205 | - // 录制选项 | ||
| 206 | - recordSetting = new PLRecordSetting(); | ||
| 207 | -// 最大录制时常 | ||
| 208 | - recordSetting.setMaxRecordDuration(mActivity.mOptions.getMaxTime()); | ||
| 209 | - recordSetting.setRecordSpeedVariable(true); | ||
| 210 | - recordSetting.setDisplayMode(PLDisplayMode.FULL); | 75 | + public void processFullScreen() { |
| 211 | 76 | ||
| 212 | - | ||
| 213 | - if (TextUtils.isEmpty(mActivity.mOptions.getCachePath())) { | ||
| 214 | - if (AndroidQUtil.isAndroidQ()) { | ||
| 215 | - videoCaceDirPath = mActivity.getExternalFilesDir("").getPath() + File.separator + "MediaPickerVideo"; | ||
| 216 | - } else { | ||
| 217 | - videoCaceDirPath = Environment.getExternalStorageDirectory().getPath() + File.separator + "MediaPickerVideo"; | ||
| 218 | - } | ||
| 219 | - } else { | ||
| 220 | - if (AndroidQUtil.isAndroidQ()) { | ||
| 221 | - videoCaceDirPath = mActivity.getExternalFilesDir("").getPath() + File.separator + "MediaPickerVideo"; | ||
| 222 | - }else { | ||
| 223 | - videoCaceDirPath= mActivity.mOptions.getCachePath(); | ||
| 224 | - } | ||
| 225 | - } | ||
| 226 | - mActivity.mOptions.setCachePath(videoCaceDirPath); | ||
| 227 | - recordSetting.setVideoCacheDir(videoCaceDirPath); | ||
| 228 | - | ||
| 229 | - mActivity.videoPath = mActivity.mOptions.getCachePath() + System.currentTimeMillis() + ".mp4"; | ||
| 230 | - recordSetting.setVideoFilepath(mActivity.videoPath); | ||
| 231 | - mActivity.binding.rcControl.setFlashState(false); | ||
| 232 | - mActivity.binding.rcControl.setMaxTime(mActivity.mOptions.getMaxTime()); | ||
| 233 | - | ||
| 234 | - //设置闪光灯 | ||
| 235 | - | ||
| 236 | - // 设置录制速度 (默认为 1.0) | ||
| 237 | - mActivity.plShortVideoRecorder.setRecordStateListener(this); | ||
| 238 | - mActivity.plShortVideoRecorder.prepare(mActivity.binding.gSf, cameraSetting, microphoneSetting, videoEncodeSetting, audioEncodeSetting,null, recordSetting); | ||
| 239 | - //处理手动对焦事件 | ||
| 240 | - | ||
| 241 | - mActivity.binding.gSf.setOnTouchListener(new View.OnTouchListener() { | ||
| 242 | - @Override | ||
| 243 | - public boolean onTouch(View v, MotionEvent event) { | ||
| 244 | - if (event.getAction() == MotionEvent.ACTION_UP) { | ||
| 245 | - moveFocus(event.getRawX(), event.getRawY()); | ||
| 246 | - } | ||
| 247 | - return true; | ||
| 248 | - } | ||
| 249 | - }); | ||
| 250 | - //如果是裁剪类型只支持拍照 | ||
| 251 | - if (mActivity.isJumpCamera && mActivity.mOptions.getJumpCameraMode() >= 0) { | ||
| 252 | - mActivity.binding.rcControl.setRecordType(mActivity.mOptions.getJumpCameraMode()); | ||
| 253 | - } else { | ||
| 254 | - if (mActivity.mOptions.isNeedCrop()) { | ||
| 255 | - mActivity.binding.rcControl.setRecordType(PickerConfig.CAMERA_MODE_PIC); | ||
| 256 | - } else { | ||
| 257 | - mActivity.binding.rcControl.setRecordType(PickerConfig.CAMERA_MODE_ALL); | ||
| 258 | - } | 77 | + WindowManager.LayoutParams lp= mActivity.getWindow().getAttributes(); |
| 78 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||
| 79 | + lp.layoutInDisplayCutoutMode =WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; | ||
| 259 | } | 80 | } |
| 81 | + mActivity.getWindow().setAttributes(lp); | ||
| 82 | + // 设置页面全屏显示 | ||
| 83 | + View decorView = mActivity.getWindow().getDecorView(); | ||
| 84 | + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_STABLE); | ||
| 260 | } | 85 | } |
| 261 | 86 | ||
| 262 | - //移动对焦的动画 | ||
| 263 | - public void moveFocus(float x, float y) { | ||
| 264 | - | ||
| 265 | - mActivity.plShortVideoRecorder.manualFocus(80, 80, (int) x, (int) y); | ||
| 266 | - //缩小 | ||
| 267 | - float transX = x - ScreenUtils.getScreenWidth(mActivity) / 2; | ||
| 268 | - | ||
| 269 | - float transY = y - ScreenUtils.getScreenHeight(mActivity) / 2; | ||
| 270 | - ObjectAnimator translationX = ObjectAnimator.ofFloat(mActivity.binding.fv, "translationX", 0, transX); | ||
| 271 | - ObjectAnimator translationY = ObjectAnimator.ofFloat(mActivity.binding.fv, "translationY", 0, transY); | ||
| 272 | - AnimatorSet animSet = new AnimatorSet(); | ||
| 273 | - animSet.play(translationX).with(translationY); | ||
| 274 | - animSet.start(); | ||
| 275 | - animSet.addListener(new Animator.AnimatorListener() { | ||
| 276 | - @Override | ||
| 277 | - public void onAnimationStart(Animator animation) { | ||
| 278 | - | ||
| 279 | - } | ||
| 280 | - | ||
| 281 | - @Override | ||
| 282 | - public void onAnimationEnd(Animator animation) { | ||
| 283 | - mActivity.binding.fv.setVisibility(View.VISIBLE); | ||
| 284 | - } | ||
| 285 | - | ||
| 286 | - @Override | ||
| 287 | - public void onAnimationCancel(Animator animation) { | ||
| 288 | - | ||
| 289 | - } | ||
| 290 | - | ||
| 291 | - @Override | ||
| 292 | - public void onAnimationRepeat(Animator animation) { | ||
| 293 | - | ||
| 294 | - } | ||
| 295 | - }); | ||
| 296 | - ObjectAnimator scaleX = ObjectAnimator.ofFloat(mActivity.binding.fv, "scaleX", 1, 0.6f); | ||
| 297 | - ObjectAnimator scaleY = ObjectAnimator.ofFloat(mActivity.binding.fv, "scaleY", 1, 0.6f); | ||
| 298 | - | ||
| 299 | - AnimatorSet animSet2 = new AnimatorSet(); | ||
| 300 | - animSet2.play(scaleY).with(scaleX); | ||
| 301 | - animSet2.setInterpolator(new OvershootInterpolator()); | ||
| 302 | - animSet2.setDuration(800); | ||
| 303 | - animSet2.start(); | ||
| 304 | - animSet2.addListener(new Animator.AnimatorListener() { | ||
| 305 | 87 | ||
| 306 | - @Override | ||
| 307 | - public void onAnimationStart(Animator animation) { | ||
| 308 | - | ||
| 309 | - } | ||
| 310 | - | ||
| 311 | - @Override | ||
| 312 | - public void onAnimationEnd(Animator animation) { | ||
| 313 | - mActivity.binding.fv.setVisibility(View.GONE); | ||
| 314 | - } | ||
| 315 | - | ||
| 316 | - @Override | ||
| 317 | - public void onAnimationCancel(Animator animation) { | ||
| 318 | - | ||
| 319 | - } | ||
| 320 | - | ||
| 321 | - @Override | ||
| 322 | - public void onAnimationRepeat(Animator animation) { | ||
| 323 | - | ||
| 324 | - } | ||
| 325 | - }); | ||
| 326 | - } | ||
| 327 | - | ||
| 328 | - public void showMesage(String message) { | 88 | + public void showMessage(String message) { |
| 329 | 89 | ||
| 330 | if (TextUtils.isEmpty(message) || mActivity == null || mActivity.isFinishing()) return; | 90 | if (TextUtils.isEmpty(message) || mActivity == null || mActivity.isFinishing()) return; |
| 331 | mActivity.runOnUiThread(new Runnable() { | 91 | mActivity.runOnUiThread(new Runnable() { |
| @@ -338,33 +98,7 @@ public class RecordView implements MvpView, PLRecordStateListener { | @@ -338,33 +98,7 @@ public class RecordView implements MvpView, PLRecordStateListener { | ||
| 338 | 98 | ||
| 339 | } | 99 | } |
| 340 | 100 | ||
| 341 | - public void processError(int code) { | ||
| 342 | - showMesage("相机异常:" + code); | ||
| 343 | - if (PLErrorCode.ERROR_UNAUTHORIZED != code) { | ||
| 344 | - initQNRecord(); | ||
| 345 | - } | ||
| 346 | - } | ||
| 347 | 101 | ||
| 348 | - public void processFlash(boolean isFlashingState) { | ||
| 349 | - mActivity.binding.rcControl.setFlashState(isFlashingState); | ||
| 350 | - } | ||
| 351 | - | ||
| 352 | - public void showPreViewImg(Bitmap plbitMap) { | ||
| 353 | - mActivity.runOnUiThread(new Runnable() { | ||
| 354 | - @Override | ||
| 355 | - public void run() { | ||
| 356 | - if (plbitMap != null && plbitMap.getByteCount() > 0) { | ||
| 357 | - showPre(); | ||
| 358 | - mActivity.preBitmap = plbitMap; | ||
| 359 | - mActivity.getSupportFragmentManager().beginTransaction().add(R.id.pre_frame, RecordPreviewFragment.newInstance(0, "")).addToBackStack("").commit(); | ||
| 360 | - | ||
| 361 | - } else { | ||
| 362 | - showMesage("相机异常"); | ||
| 363 | - } | ||
| 364 | - } | ||
| 365 | - }); | ||
| 366 | - | ||
| 367 | - } | ||
| 368 | 102 | ||
| 369 | 103 | ||
| 370 | public void showPermission(String[] needList, int requestCode) { | 104 | public void showPermission(String[] needList, int requestCode) { |
| @@ -378,7 +112,7 @@ public class RecordView implements MvpView, PLRecordStateListener { | @@ -378,7 +112,7 @@ public class RecordView implements MvpView, PLRecordStateListener { | ||
| 378 | @Override | 112 | @Override |
| 379 | public void onClickLeft(Dialog dialog) { | 113 | public void onClickLeft(Dialog dialog) { |
| 380 | dialog.dismiss(); | 114 | dialog.dismiss(); |
| 381 | - showMesage("无法获取存读取权限,您的app将无法正常使用"); | 115 | + showMessage("无法获取存读取权限,您的app将无法正常使用"); |
| 382 | mActivity.finish(); | 116 | mActivity.finish(); |
| 383 | } | 117 | } |
| 384 | 118 | ||
| @@ -402,7 +136,7 @@ public class RecordView implements MvpView, PLRecordStateListener { | @@ -402,7 +136,7 @@ public class RecordView implements MvpView, PLRecordStateListener { | ||
| 402 | @Override | 136 | @Override |
| 403 | public void onClickLeft(Dialog dialog) { | 137 | public void onClickLeft(Dialog dialog) { |
| 404 | dialog.dismiss(); | 138 | dialog.dismiss(); |
| 405 | - showMesage("无法获取存读取权限,您的app将无法正常使用"); | 139 | + showMessage("无法获取存读取权限,您的app将无法正常使用"); |
| 406 | mActivity.finish(); | 140 | mActivity.finish(); |
| 407 | } | 141 | } |
| 408 | 142 |
lib_media/src/main/java/com/cnlive/media/meidia/DataCallback.java renamed to lib_media/src/main/java/com/cnlive/media/media/DataCallback.java
lib_media/src/main/java/com/cnlive/media/meidia/entity/Folder.java renamed to lib_media/src/main/java/com/cnlive/media/media/entity/Folder.java
lib_media/src/main/java/com/cnlive/media/meidia/entity/Media.java renamed to lib_media/src/main/java/com/cnlive/media/media/entity/Media.java
lib_media/src/main/java/com/cnlive/media/meidia/loader/ImageLoader.java renamed to lib_media/src/main/java/com/cnlive/media/media/loader/ImageLoader.java
| 1 | -package com.cnlive.media.meidia.loader; | 1 | +package com.cnlive.media.media.loader; |
| 2 | 2 | ||
| 3 | import android.app.LoaderManager; | 3 | import android.app.LoaderManager; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| @@ -10,9 +10,9 @@ import android.os.Bundle; | @@ -10,9 +10,9 @@ import android.os.Bundle; | ||
| 10 | import android.provider.MediaStore; | 10 | import android.provider.MediaStore; |
| 11 | import android.text.TextUtils; | 11 | import android.text.TextUtils; |
| 12 | 12 | ||
| 13 | -import com.cnlive.media.meidia.DataCallback; | ||
| 14 | -import com.cnlive.media.meidia.entity.Folder; | ||
| 15 | -import com.cnlive.media.meidia.entity.Media; | 13 | +import com.cnlive.media.media.DataCallback; |
| 14 | +import com.cnlive.media.media.entity.Folder; | ||
| 15 | +import com.cnlive.media.media.entity.Media; | ||
| 16 | import com.cnlive.media.utils.MediaUtils; | 16 | import com.cnlive.media.utils.MediaUtils; |
| 17 | import com.cnlive.media.R; | 17 | import com.cnlive.media.R; |
| 18 | 18 |
lib_media/src/main/java/com/cnlive/media/meidia/loader/LoaderM.java renamed to lib_media/src/main/java/com/cnlive/media/media/loader/LoaderM.java
lib_media/src/main/java/com/cnlive/media/meidia/loader/MediaLoader.java renamed to lib_media/src/main/java/com/cnlive/media/media/loader/MediaLoader.java
| 1 | -package com.cnlive.media.meidia.loader; | 1 | +package com.cnlive.media.media.loader; |
| 2 | 2 | ||
| 3 | import android.app.LoaderManager; | 3 | import android.app.LoaderManager; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| @@ -10,9 +10,9 @@ import android.os.Bundle; | @@ -10,9 +10,9 @@ import android.os.Bundle; | ||
| 10 | import android.provider.MediaStore; | 10 | import android.provider.MediaStore; |
| 11 | import android.text.TextUtils; | 11 | import android.text.TextUtils; |
| 12 | 12 | ||
| 13 | -import com.cnlive.media.meidia.DataCallback; | ||
| 14 | -import com.cnlive.media.meidia.entity.Folder; | ||
| 15 | -import com.cnlive.media.meidia.entity.Media; | 13 | +import com.cnlive.media.media.DataCallback; |
| 14 | +import com.cnlive.media.media.entity.Folder; | ||
| 15 | +import com.cnlive.media.media.entity.Media; | ||
| 16 | import com.cnlive.media.utils.MediaUtils; | 16 | import com.cnlive.media.utils.MediaUtils; |
| 17 | import com.cnlive.media.R; | 17 | import com.cnlive.media.R; |
| 18 | 18 |
lib_media/src/main/java/com/cnlive/media/meidia/loader/VideoLoader.java renamed to lib_media/src/main/java/com/cnlive/media/media/loader/VideoLoader.java
| 1 | -package com.cnlive.media.meidia.loader; | 1 | +package com.cnlive.media.media.loader; |
| 2 | 2 | ||
| 3 | import android.app.LoaderManager; | 3 | import android.app.LoaderManager; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| @@ -12,9 +12,9 @@ import android.text.TextUtils; | @@ -12,9 +12,9 @@ import android.text.TextUtils; | ||
| 12 | import android.util.Log; | 12 | import android.util.Log; |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | -import com.cnlive.media.meidia.DataCallback; | ||
| 16 | -import com.cnlive.media.meidia.entity.Folder; | ||
| 17 | -import com.cnlive.media.meidia.entity.Media; | 15 | +import com.cnlive.media.media.DataCallback; |
| 16 | +import com.cnlive.media.media.entity.Folder; | ||
| 17 | +import com.cnlive.media.media.entity.Media; | ||
| 18 | import com.cnlive.media.R; | 18 | import com.cnlive.media.R; |
| 19 | 19 | ||
| 20 | import java.io.File; | 20 | import java.io.File; |
lib_media/src/main/java/com/cnlive/media/model/ImagePickerOptions.java
| @@ -4,7 +4,7 @@ import android.os.Parcel; | @@ -4,7 +4,7 @@ import android.os.Parcel; | ||
| 4 | import android.os.Parcelable; | 4 | import android.os.Parcelable; |
| 5 | 5 | ||
| 6 | import com.cnlive.media.PickerConfig; | 6 | import com.cnlive.media.PickerConfig; |
| 7 | -import com.cnlive.media.meidia.entity.Media; | 7 | +import com.cnlive.media.media.entity.Media; |
| 8 | 8 | ||
| 9 | import java.util.ArrayList; | 9 | import java.util.ArrayList; |
| 10 | 10 |
lib_media/src/main/java/com/cnlive/media/ui/activity/MediaActivity.java
| @@ -13,15 +13,16 @@ import androidx.fragment.app.Fragment; | @@ -13,15 +13,16 @@ import androidx.fragment.app.Fragment; | ||
| 13 | import com.cnlive.libs.base.frame.activity.MvpBindingActivity; | 13 | import com.cnlive.libs.base.frame.activity.MvpBindingActivity; |
| 14 | import com.cnlive.media.PickerConfig; | 14 | import com.cnlive.media.PickerConfig; |
| 15 | import com.cnlive.media.R; | 15 | import com.cnlive.media.R; |
| 16 | +import com.cnlive.media.databinding.ActivityMediaBinding; | ||
| 16 | import com.cnlive.media.frame.presenter.MediaPresenter; | 17 | import com.cnlive.media.frame.presenter.MediaPresenter; |
| 17 | import com.cnlive.media.frame.view.MediaView; | 18 | import com.cnlive.media.frame.view.MediaView; |
| 18 | -import com.cnlive.media.meidia.DataCallback; | ||
| 19 | -import com.cnlive.media.meidia.entity.Folder; | ||
| 20 | -import com.cnlive.media.meidia.entity.Media; | ||
| 21 | -import com.cnlive.media.meidia.loader.ImageLoader; | ||
| 22 | -import com.cnlive.media.meidia.loader.LoaderM; | ||
| 23 | -import com.cnlive.media.meidia.loader.MediaLoader; | ||
| 24 | -import com.cnlive.media.meidia.loader.VideoLoader; | 19 | +import com.cnlive.media.media.DataCallback; |
| 20 | +import com.cnlive.media.media.entity.Folder; | ||
| 21 | +import com.cnlive.media.media.entity.Media; | ||
| 22 | +import com.cnlive.media.media.loader.ImageLoader; | ||
| 23 | +import com.cnlive.media.media.loader.LoaderM; | ||
| 24 | +import com.cnlive.media.media.loader.MediaLoader; | ||
| 25 | +import com.cnlive.media.media.loader.VideoLoader; | ||
| 25 | import com.cnlive.media.model.ImagePickerCropParams; | 26 | import com.cnlive.media.model.ImagePickerCropParams; |
| 26 | import com.cnlive.media.model.ImagePickerOptions; | 27 | import com.cnlive.media.model.ImagePickerOptions; |
| 27 | import com.cnlive.media.ui.adapter.FolderAdapter; | 28 | import com.cnlive.media.ui.adapter.FolderAdapter; |
| @@ -33,7 +34,6 @@ import com.cnlive.media.utils.observable.MediaOpenInfo; | @@ -33,7 +34,6 @@ import com.cnlive.media.utils.observable.MediaOpenInfo; | ||
| 33 | import com.cnlive.media.utils.observable.MediaPageSelectStateObservable; | 34 | import com.cnlive.media.utils.observable.MediaPageSelectStateObservable; |
| 34 | import com.cnlive.media.utils.observable.MediaSelectStateObservable; | 35 | import com.cnlive.media.utils.observable.MediaSelectStateObservable; |
| 35 | import com.cnlive.media.utils.observable.MeidaResultObservable; | 36 | import com.cnlive.media.utils.observable.MeidaResultObservable; |
| 36 | -import com.cnlive.media.databinding.ActivityMediaBinding; | ||
| 37 | 37 | ||
| 38 | import java.io.File; | 38 | import java.io.File; |
| 39 | import java.util.ArrayList; | 39 | import java.util.ArrayList; |
| @@ -41,7 +41,6 @@ import java.util.List; | @@ -41,7 +41,6 @@ import java.util.List; | ||
| 41 | import java.util.Observable; | 41 | import java.util.Observable; |
| 42 | import java.util.Observer; | 42 | import java.util.Observer; |
| 43 | 43 | ||
| 44 | - | ||
| 45 | import static com.cnlive.media.PickerConfig.REQUEST_CODE_PERMISSION_CAMERA; | 44 | import static com.cnlive.media.PickerConfig.REQUEST_CODE_PERMISSION_CAMERA; |
| 46 | import static com.cnlive.media.PickerConfig.REQUEST_CODE_PERMISSION_CROP; | 45 | import static com.cnlive.media.PickerConfig.REQUEST_CODE_PERMISSION_CROP; |
| 47 | import static com.cnlive.media.PickerConfig.REQUEST_CODE_PERMISSION_READ; | 46 | import static com.cnlive.media.PickerConfig.REQUEST_CODE_PERMISSION_READ; |
| @@ -146,6 +145,7 @@ public class MediaActivity extends MvpBindingActivity<MediaView, MediaPresenter, | @@ -146,6 +145,7 @@ public class MediaActivity extends MvpBindingActivity<MediaView, MediaPresenter, | ||
| 146 | if (getMvpView() != null) getMvpView().initView(); | 145 | if (getMvpView() != null) getMvpView().initView(); |
| 147 | getSupportFragmentManager().beginTransaction().add(R.id.frame, MediaPickerFragment.newInstanse(), MEDIA_HOME).addToBackStack("").commit(); | 146 | getSupportFragmentManager().beginTransaction().add(R.id.frame, MediaPickerFragment.newInstanse(), MEDIA_HOME).addToBackStack("").commit(); |
| 148 | getMediaData(); | 147 | getMediaData(); |
| 148 | + | ||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | void getMediaData() { | 151 | void getMediaData() { |
lib_media/src/main/java/com/cnlive/media/ui/activity/MediaPreviewActivity.java
| @@ -7,7 +7,7 @@ import com.cnlive.media.PickerConfig; | @@ -7,7 +7,7 @@ import com.cnlive.media.PickerConfig; | ||
| 7 | import com.cnlive.media.R; | 7 | import com.cnlive.media.R; |
| 8 | import com.cnlive.media.frame.presenter.MediaPreviewViewPresenter; | 8 | import com.cnlive.media.frame.presenter.MediaPreviewViewPresenter; |
| 9 | import com.cnlive.media.frame.view.MediaPreviewViewView; | 9 | import com.cnlive.media.frame.view.MediaPreviewViewView; |
| 10 | -import com.cnlive.media.meidia.entity.Media; | 10 | +import com.cnlive.media.media.entity.Media; |
| 11 | import com.cnlive.media.ui.adapter.MediaPreviewAdapter; | 11 | import com.cnlive.media.ui.adapter.MediaPreviewAdapter; |
| 12 | import com.cnlive.media.databinding.ActivityPreviewImageBinding; | 12 | import com.cnlive.media.databinding.ActivityPreviewImageBinding; |
| 13 | 13 |
lib_media/src/main/java/com/cnlive/media/ui/activity/RecordActivity.java
| @@ -7,28 +7,22 @@ import android.content.Intent; | @@ -7,28 +7,22 @@ import android.content.Intent; | ||
| 7 | import android.graphics.Bitmap; | 7 | import android.graphics.Bitmap; |
| 8 | import android.graphics.Color; | 8 | import android.graphics.Color; |
| 9 | import android.os.Bundle; | 9 | import android.os.Bundle; |
| 10 | -import android.view.View; | ||
| 11 | 10 | ||
| 12 | import androidx.annotation.NonNull; | 11 | import androidx.annotation.NonNull; |
| 13 | import androidx.fragment.app.Fragment; | 12 | import androidx.fragment.app.Fragment; |
| 14 | 13 | ||
| 15 | import com.cnlive.libs.base.frame.activity.MvpBindingActivity; | 14 | import com.cnlive.libs.base.frame.activity.MvpBindingActivity; |
| 16 | -import com.cnlive.libs.base.util.DoublePressed; | ||
| 17 | import com.cnlive.libs.base.util.StatusBarUtil2; | 15 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 18 | import com.cnlive.media.PickerConfig; | 16 | import com.cnlive.media.PickerConfig; |
| 19 | import com.cnlive.media.R; | 17 | import com.cnlive.media.R; |
| 18 | +import com.cnlive.media.databinding.ActivityRecordBinding; | ||
| 20 | import com.cnlive.media.frame.presenter.RecordPresenter; | 19 | import com.cnlive.media.frame.presenter.RecordPresenter; |
| 21 | import com.cnlive.media.frame.view.RecordView; | 20 | import com.cnlive.media.frame.view.RecordView; |
| 22 | -import com.cnlive.media.meidia.entity.Media; | 21 | +import com.cnlive.media.media.entity.Media; |
| 23 | import com.cnlive.media.model.ImagePickerOptions; | 22 | import com.cnlive.media.model.ImagePickerOptions; |
| 24 | import com.cnlive.media.ui.fragment.RecordPreviewFragment; | 23 | import com.cnlive.media.ui.fragment.RecordPreviewFragment; |
| 25 | -import com.cnlive.media.ui.widget.record.observable.RecordCameraViewObservable; | 24 | +import com.cnlive.media.utils.QiniuVideoUtil; |
| 26 | import com.cnlive.media.utils.observable.MeidaResultObservable; | 25 | import com.cnlive.media.utils.observable.MeidaResultObservable; |
| 27 | -import com.cnlive.media.databinding.ActivityRecordBinding; | ||
| 28 | -import com.qiniu.pili.droid.shortvideo.PLCaptureFrameListener; | ||
| 29 | -import com.qiniu.pili.droid.shortvideo.PLShortVideoRecorder; | ||
| 30 | -import com.qiniu.pili.droid.shortvideo.PLVideoFrame; | ||
| 31 | -import com.qiniu.pili.droid.shortvideo.PLVideoSaveListener; | ||
| 32 | 26 | ||
| 33 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
| 34 | import java.util.Observable; | 28 | import java.util.Observable; |
| @@ -46,12 +40,6 @@ import java.util.Observer; | @@ -46,12 +40,6 @@ import java.util.Observer; | ||
| 46 | */ | 40 | */ |
| 47 | public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresenter, Object, ActivityRecordBinding> implements Observer { | 41 | public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresenter, Object, ActivityRecordBinding> implements Observer { |
| 48 | 42 | ||
| 49 | - public PLShortVideoRecorder plShortVideoRecorder; | ||
| 50 | - public boolean isFlash; | ||
| 51 | - //准备就绪 | ||
| 52 | - public boolean isReady; | ||
| 53 | - //录制中 | ||
| 54 | - public boolean isRecordIng; | ||
| 55 | 43 | ||
| 56 | public ImagePickerOptions mOptions; | 44 | public ImagePickerOptions mOptions; |
| 57 | 45 | ||
| @@ -67,6 +55,7 @@ public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresent | @@ -67,6 +55,7 @@ public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresent | ||
| 67 | public boolean isNeverAsk; | 55 | public boolean isNeverAsk; |
| 68 | public ArrayList<Media> selectMedia; | 56 | public ArrayList<Media> selectMedia; |
| 69 | // 存读取权限 | 57 | // 存读取权限 |
| 58 | + | ||
| 70 | public static String[] permissionsRecord = { | 59 | public static String[] permissionsRecord = { |
| 71 | Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}; | 60 | Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}; |
| 72 | 61 | ||
| @@ -88,13 +77,43 @@ public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresent | @@ -88,13 +77,43 @@ public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresent | ||
| 88 | this.getWindow().getDecorView().setBackgroundColor(Color.TRANSPARENT); | 77 | this.getWindow().getDecorView().setBackgroundColor(Color.TRANSPARENT); |
| 89 | StatusBarUtil2.setTransparentForWindow(this); | 78 | StatusBarUtil2.setTransparentForWindow(this); |
| 90 | StatusBarUtil2.addTranslucentView(this, 0); | 79 | StatusBarUtil2.addTranslucentView(this, 0); |
| 91 | - resultCode = getIntent().getIntExtra(PickerConfig.RESULT_CODE, 0); | ||
| 92 | - isJumpCamera = getIntent().getBooleanExtra(PickerConfig.WHERE_JUMP_CAMERA, false); | ||
| 93 | - selectMedia = getIntent().getParcelableArrayListExtra(PickerConfig.WHERE_JUMP_CAMERA_SELECTS); | ||
| 94 | - mOptions = getIntent().getParcelableExtra(PickerConfig.INTENT_KEY_OPTIONS); | ||
| 95 | - RecordCameraViewObservable.newInstance().addObserver(this); | ||
| 96 | - MeidaResultObservable.getInstance().addObserver(this); | ||
| 97 | - if (getMvpView() != null) getMvpView().initView(); | 80 | + QiniuVideoUtil.chcekInitState(this, isInit -> { |
| 81 | + if (isInit) { | ||
| 82 | + resultCode = getIntent().getIntExtra(PickerConfig.RESULT_CODE, 0); | ||
| 83 | + isJumpCamera = getIntent().getBooleanExtra(PickerConfig.WHERE_JUMP_CAMERA, false); | ||
| 84 | + selectMedia = getIntent().getParcelableArrayListExtra(PickerConfig.WHERE_JUMP_CAMERA_SELECTS); | ||
| 85 | + mOptions = getIntent().getParcelableExtra(PickerConfig.INTENT_KEY_OPTIONS); | ||
| 86 | + MeidaResultObservable.getInstance().addObserver(this); | ||
| 87 | + if (getMvpView() != null) getMvpView().initView(); | ||
| 88 | + } else { | ||
| 89 | + getMvpView().showMessage("初始化异常"); | ||
| 90 | + onBackPressed(); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + }); | ||
| 94 | + | ||
| 95 | + | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public void showPreViewImg(Bitmap plbitMap) { | ||
| 99 | + runOnUiThread(new Runnable() { | ||
| 100 | + @Override | ||
| 101 | + public void run() { | ||
| 102 | + preBitmap = plbitMap; | ||
| 103 | + getSupportFragmentManager().beginTransaction().add(R.id.pre_frame, RecordPreviewFragment.newInstance(0, "")).addToBackStack("").commit(); | ||
| 104 | + } | ||
| 105 | + }); | ||
| 106 | + | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public void showVideo(String path) { | ||
| 110 | + runOnUiThread(new Runnable() { | ||
| 111 | + @Override | ||
| 112 | + public void run() { | ||
| 113 | + getSupportFragmentManager().beginTransaction().replace(R.id.pre_frame, RecordPreviewFragment.newInstance(1, path)).addToBackStack("").commit(); | ||
| 114 | + } | ||
| 115 | + }); | ||
| 116 | + | ||
| 98 | } | 117 | } |
| 99 | 118 | ||
| 100 | @Override | 119 | @Override |
| @@ -121,29 +140,18 @@ public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresent | @@ -121,29 +140,18 @@ public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresent | ||
| 121 | @Override | 140 | @Override |
| 122 | protected void onResume() { | 141 | protected void onResume() { |
| 123 | super.onResume(); | 142 | super.onResume(); |
| 124 | - if (isFlash && getMvpView() != null) getMvpView().processFlash(isFlash); | ||
| 125 | - if (plShortVideoRecorder != null) plShortVideoRecorder.resume(); | ||
| 126 | - if (isNeverAsk) { | ||
| 127 | - isNeverAsk = false; | ||
| 128 | - //永久拒绝后,返回页面时检测权限并初始化 | ||
| 129 | - if (getMvpView() != null) getMvpView().checkPermisssion(); | ||
| 130 | - } | ||
| 131 | 143 | ||
| 132 | } | 144 | } |
| 133 | 145 | ||
| 134 | @Override | 146 | @Override |
| 135 | protected void onPause() { | 147 | protected void onPause() { |
| 136 | super.onPause(); | 148 | super.onPause(); |
| 137 | - isRecordIng=false; | ||
| 138 | - if (plShortVideoRecorder != null) plShortVideoRecorder.pause(); | ||
| 139 | } | 149 | } |
| 140 | 150 | ||
| 141 | @Override | 151 | @Override |
| 142 | protected void onDestroy() { | 152 | protected void onDestroy() { |
| 143 | super.onDestroy(); | 153 | super.onDestroy(); |
| 144 | - if (plShortVideoRecorder != null) plShortVideoRecorder.destroy(); | ||
| 145 | MeidaResultObservable.getInstance().deleteObserver(this); | 154 | MeidaResultObservable.getInstance().deleteObserver(this); |
| 146 | - RecordCameraViewObservable.newInstance().deleteObserver(this); | ||
| 147 | if (preBitmap != null) { | 155 | if (preBitmap != null) { |
| 148 | // glide 加载维护了 bitmap 回收 | 156 | // glide 加载维护了 bitmap 回收 |
| 149 | // if (!preBitmap.isRecycled()){ | 157 | // if (!preBitmap.isRecycled()){ |
| @@ -157,115 +165,29 @@ public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresent | @@ -157,115 +165,29 @@ public class RecordActivity extends MvpBindingActivity<RecordView, RecordPresent | ||
| 157 | 165 | ||
| 158 | @Override | 166 | @Override |
| 159 | public void update(Observable o, Object arg) { | 167 | public void update(Observable o, Object arg) { |
| 160 | - if (o instanceof RecordCameraViewObservable) { | ||
| 161 | - int state = (int) arg; | ||
| 162 | - if (plShortVideoRecorder == null || getMvpView() == null) return; | ||
| 163 | - //闪光灯 | ||
| 164 | - if (state == RecordCameraViewObservable.CLICK_FLASH) { | ||
| 165 | - if (isRecordIng) { | ||
| 166 | - getMvpView().showMesage("录制中..."); | ||
| 167 | - } else { | ||
| 168 | - if (plShortVideoRecorder.isFlashSupport()) { | ||
| 169 | - isFlash = (!isFlash); | ||
| 170 | - plShortVideoRecorder.setFlashEnabled(isFlash); | ||
| 171 | - getMvpView().processFlash(isFlash); | ||
| 172 | - } else { | ||
| 173 | - isFlash = false; | ||
| 174 | - getMvpView().processFlash(false); | ||
| 175 | - getMvpView().showMesage("暂不支持闪光灯"); | ||
| 176 | - } | ||
| 177 | - } | ||
| 178 | - | ||
| 179 | - } else if (state == RecordCameraViewObservable.CLICK_SWITCH) { | ||
| 180 | - if (isRecordIng) { | ||
| 181 | - //设置前后摄像头 | ||
| 182 | - getMvpView().showMesage("录制中..."); | ||
| 183 | - | ||
| 184 | - } else { | ||
| 185 | - if (DoublePressed.onDoublePressed()) return; | ||
| 186 | - plShortVideoRecorder.switchCamera(); | ||
| 187 | - } | ||
| 188 | - } else if (state == RecordCameraViewObservable.CLICK_FINISH) { | ||
| 189 | - finish(); | ||
| 190 | - } else if (state == RecordCameraViewObservable.CLICK_TAKE) { | ||
| 191 | - //拍照 | ||
| 192 | - if (isReady) { | ||
| 193 | - plShortVideoRecorder.captureFrame(new PLCaptureFrameListener() { | ||
| 194 | - @Override | ||
| 195 | - public void onFrameCaptured(PLVideoFrame plVideoFrame) { | ||
| 196 | - Bitmap plbitMap = plVideoFrame.toBitmap(); | ||
| 197 | - getMvpView().showPreViewImg(plbitMap); | ||
| 198 | - } | ||
| 199 | - }); | ||
| 200 | - } | ||
| 201 | - | ||
| 202 | - | ||
| 203 | - } else if (state == RecordCameraViewObservable.CLICK_RECODE_START) { | ||
| 204 | - //视频录制开始 | ||
| 205 | - if (isReady) { | ||
| 206 | - isRecordIng = true; | ||
| 207 | - plShortVideoRecorder.deleteLastSection(); | ||
| 208 | - plShortVideoRecorder.beginSection(); | ||
| 209 | - } else { | ||
| 210 | - isRecordIng = false; | ||
| 211 | - getMvpView().showMesage("相机还未准备完成,请稍后"); | ||
| 212 | - } | ||
| 213 | - } else if (state == RecordCameraViewObservable.CLICK_RECODE_FINISH) { | ||
| 214 | - //录制完成 | ||
| 215 | - plShortVideoRecorder.endSection(); | ||
| 216 | - plShortVideoRecorder.concatSections(new PLVideoSaveListener() { | ||
| 217 | - //视频保存完成 | ||
| 218 | - @Override | ||
| 219 | - public void onSaveVideoSuccess(String s) { | ||
| 220 | - isRecordIng = false; | ||
| 221 | - getMvpView().showPre(); | ||
| 222 | - getSupportFragmentManager().beginTransaction().replace(R.id.pre_frame, RecordPreviewFragment.newInstance(1, s)).addToBackStack("").commit(); | ||
| 223 | - | ||
| 224 | - } | ||
| 225 | - | ||
| 226 | - @Override | ||
| 227 | - public void onSaveVideoFailed(int i) { | ||
| 228 | - isRecordIng = false; | ||
| 229 | - if (getMvpView() != null) getMvpView().showMesage("视频录制失败"); | ||
| 230 | - } | ||
| 231 | - | ||
| 232 | - @Override | ||
| 233 | - public void onSaveVideoCanceled() { | ||
| 234 | - | ||
| 235 | - } | ||
| 236 | - | ||
| 237 | - @Override | ||
| 238 | - public void onProgressUpdate(float v) { | ||
| 239 | - | ||
| 240 | - } | ||
| 241 | - }); | ||
| 242 | - | ||
| 243 | - } | ||
| 244 | - } else if (o instanceof MeidaResultObservable) { | 168 | + if (o instanceof MeidaResultObservable) { |
| 245 | Media media = (Media) arg; | 169 | Media media = (Media) arg; |
| 246 | if (isJumpCamera) { | 170 | if (isJumpCamera) { |
| 247 | if (selectMedia == null) | 171 | if (selectMedia == null) |
| 248 | - selectMedia = new ArrayList<Media>(); | 172 | + selectMedia = new ArrayList<Media>(); |
| 249 | selectMedia.add(media); | 173 | selectMedia.add(media); |
| 250 | Intent intent = new Intent(); | 174 | Intent intent = new Intent(); |
| 251 | intent.putParcelableArrayListExtra(PickerConfig.EXTRA_RESULT, selectMedia); | 175 | intent.putParcelableArrayListExtra(PickerConfig.EXTRA_RESULT, selectMedia); |
| 252 | setResult(resultCode, intent); | 176 | setResult(resultCode, intent); |
| 253 | finish(); | 177 | finish(); |
| 254 | - }else { | 178 | + } else { |
| 255 | finish(); | 179 | finish(); |
| 256 | } | 180 | } |
| 257 | } | 181 | } |
| 258 | 182 | ||
| 259 | } | 183 | } |
| 260 | 184 | ||
| 185 | + | ||
| 261 | @Override | 186 | @Override |
| 262 | public void onBackPressed() { | 187 | public void onBackPressed() { |
| 263 | Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.pre_frame); | 188 | Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.pre_frame); |
| 264 | if (currentFragment == null) super.onBackPressed(); | 189 | if (currentFragment == null) super.onBackPressed(); |
| 265 | if (currentFragment instanceof RecordPreviewFragment) { | 190 | if (currentFragment instanceof RecordPreviewFragment) { |
| 266 | - binding.gSf.setVisibility(View.VISIBLE); | ||
| 267 | - binding.rcControl.setVisibility(View.VISIBLE); | ||
| 268 | - binding.preFrame.setVisibility(View.GONE); | ||
| 269 | getSupportFragmentManager().popBackStack(); | 191 | getSupportFragmentManager().popBackStack(); |
| 270 | } else { | 192 | } else { |
| 271 | finish(); | 193 | finish(); |
lib_media/src/main/java/com/cnlive/media/ui/adapter/FolderAdapter.java
| @@ -12,8 +12,8 @@ import androidx.core.content.ContextCompat; | @@ -12,8 +12,8 @@ import androidx.core.content.ContextCompat; | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | import com.cnlive.media.R; | 14 | import com.cnlive.media.R; |
| 15 | -import com.cnlive.media.meidia.entity.Folder; | ||
| 16 | -import com.cnlive.media.meidia.entity.Media; | 15 | +import com.cnlive.media.media.entity.Folder; |
| 16 | +import com.cnlive.media.media.entity.Media; | ||
| 17 | import com.cnlive.media.utils.GlideCacheUtil; | 17 | import com.cnlive.media.utils.GlideCacheUtil; |
| 18 | 18 | ||
| 19 | import java.util.ArrayList; | 19 | import java.util.ArrayList; |
lib_media/src/main/java/com/cnlive/media/ui/adapter/MediaAdapter.java
| @@ -15,7 +15,7 @@ import androidx.recyclerview.widget.RecyclerView; | @@ -15,7 +15,7 @@ import androidx.recyclerview.widget.RecyclerView; | ||
| 15 | import com.cnlive.libs.base.util.StringUtils; | 15 | import com.cnlive.libs.base.util.StringUtils; |
| 16 | import com.cnlive.media.PickerConfig; | 16 | import com.cnlive.media.PickerConfig; |
| 17 | import com.cnlive.media.R; | 17 | import com.cnlive.media.R; |
| 18 | -import com.cnlive.media.meidia.entity.Media; | 18 | +import com.cnlive.media.media.entity.Media; |
| 19 | import com.cnlive.media.model.ImagePickerOptions; | 19 | import com.cnlive.media.model.ImagePickerOptions; |
| 20 | import com.cnlive.media.utils.FileUtils; | 20 | import com.cnlive.media.utils.FileUtils; |
| 21 | import com.cnlive.media.utils.GlideCacheUtil; | 21 | import com.cnlive.media.utils.GlideCacheUtil; |
lib_media/src/main/java/com/cnlive/media/ui/adapter/MediaPreviewAdapter.java
| @@ -5,7 +5,7 @@ import androidx.fragment.app.Fragment; | @@ -5,7 +5,7 @@ import androidx.fragment.app.Fragment; | ||
| 5 | import androidx.fragment.app.FragmentActivity; | 5 | import androidx.fragment.app.FragmentActivity; |
| 6 | import androidx.viewpager2.adapter.FragmentStateAdapter; | 6 | import androidx.viewpager2.adapter.FragmentStateAdapter; |
| 7 | 7 | ||
| 8 | -import com.cnlive.media.meidia.entity.Media; | 8 | +import com.cnlive.media.media.entity.Media; |
| 9 | import com.cnlive.media.ui.fragment.MediaFragment; | 9 | import com.cnlive.media.ui.fragment.MediaFragment; |
| 10 | 10 | ||
| 11 | import java.util.ArrayList; | 11 | import java.util.ArrayList; |
| @@ -31,7 +31,7 @@ public class MediaPreviewAdapter extends FragmentStateAdapter { | @@ -31,7 +31,7 @@ public class MediaPreviewAdapter extends FragmentStateAdapter { | ||
| 31 | @NonNull | 31 | @NonNull |
| 32 | @Override | 32 | @Override |
| 33 | public Fragment createFragment(int position) { | 33 | public Fragment createFragment(int position) { |
| 34 | - return MediaFragment.newInstanse(mediaList.get(position)); | 34 | + return MediaFragment.newInstance(mediaList.get(position)); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | @Override | 37 | @Override |
lib_media/src/main/java/com/cnlive/media/ui/adapter/OnItemClickListener.java
lib_media/src/main/java/com/cnlive/media/ui/adapter/PreviewBottomAdapter.java
| @@ -11,7 +11,7 @@ import androidx.recyclerview.widget.RecyclerView; | @@ -11,7 +11,7 @@ import androidx.recyclerview.widget.RecyclerView; | ||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | import com.cnlive.media.R; | 13 | import com.cnlive.media.R; |
| 14 | -import com.cnlive.media.meidia.entity.Media; | 14 | +import com.cnlive.media.media.entity.Media; |
| 15 | import com.cnlive.media.utils.GlideCacheUtil; | 15 | import com.cnlive.media.utils.GlideCacheUtil; |
| 16 | 16 | ||
| 17 | import java.util.ArrayList; | 17 | import java.util.ArrayList; |
lib_media/src/main/java/com/cnlive/media/ui/adapter/PreviewBottomMediaAdapter.java
| @@ -9,7 +9,7 @@ import androidx.databinding.DataBindingUtil; | @@ -9,7 +9,7 @@ import androidx.databinding.DataBindingUtil; | ||
| 9 | import androidx.recyclerview.widget.RecyclerView; | 9 | import androidx.recyclerview.widget.RecyclerView; |
| 10 | 10 | ||
| 11 | import com.cnlive.media.R; | 11 | import com.cnlive.media.R; |
| 12 | -import com.cnlive.media.meidia.entity.Media; | 12 | +import com.cnlive.media.media.entity.Media; |
| 13 | import com.cnlive.media.utils.GlideCacheUtil; | 13 | import com.cnlive.media.utils.GlideCacheUtil; |
| 14 | import com.cnlive.media.databinding.MediaPreviewBottomBarItemBinding; | 14 | import com.cnlive.media.databinding.MediaPreviewBottomBarItemBinding; |
| 15 | 15 |
lib_media/src/main/java/com/cnlive/media/ui/fragment/MediaFragment.java
| @@ -9,7 +9,7 @@ import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | @@ -9,7 +9,7 @@ import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | ||
| 9 | import com.cnlive.media.R; | 9 | import com.cnlive.media.R; |
| 10 | import com.cnlive.media.frame.presenter.MediaFPresenter; | 10 | import com.cnlive.media.frame.presenter.MediaFPresenter; |
| 11 | import com.cnlive.media.frame.view.MediaFView; | 11 | import com.cnlive.media.frame.view.MediaFView; |
| 12 | -import com.cnlive.media.meidia.entity.Media; | 12 | +import com.cnlive.media.media.entity.Media; |
| 13 | import com.cnlive.media.databinding.FragmentMediaBinding; | 13 | import com.cnlive.media.databinding.FragmentMediaBinding; |
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| @@ -25,7 +25,7 @@ public class MediaFragment extends MvpBindingFragment<MediaFView, MediaFPresente | @@ -25,7 +25,7 @@ public class MediaFragment extends MvpBindingFragment<MediaFView, MediaFPresente | ||
| 25 | 25 | ||
| 26 | public Media mMedia; | 26 | public Media mMedia; |
| 27 | 27 | ||
| 28 | - public static MediaFragment newInstanse(Media mMedia) { | 28 | + public static MediaFragment newInstance(Media mMedia) { |
| 29 | 29 | ||
| 30 | MediaFragment fragment = new MediaFragment(); | 30 | MediaFragment fragment = new MediaFragment(); |
| 31 | Bundle bundle = new Bundle(); | 31 | Bundle bundle = new Bundle(); |
lib_media/src/main/java/com/cnlive/media/ui/fragment/MediaPickerFragment.java
| @@ -11,8 +11,8 @@ import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | @@ -11,8 +11,8 @@ import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | ||
| 11 | import com.cnlive.media.R; | 11 | import com.cnlive.media.R; |
| 12 | import com.cnlive.media.frame.presenter.MediaPickerFragmentPresenter; | 12 | import com.cnlive.media.frame.presenter.MediaPickerFragmentPresenter; |
| 13 | import com.cnlive.media.frame.view.MediaPickerFragmentView; | 13 | import com.cnlive.media.frame.view.MediaPickerFragmentView; |
| 14 | -import com.cnlive.media.meidia.entity.Folder; | ||
| 15 | -import com.cnlive.media.meidia.entity.Media; | 14 | +import com.cnlive.media.media.entity.Folder; |
| 15 | +import com.cnlive.media.media.entity.Media; | ||
| 16 | import com.cnlive.media.ui.activity.MediaActivity; | 16 | import com.cnlive.media.ui.activity.MediaActivity; |
| 17 | import com.cnlive.media.ui.adapter.MediaAdapter; | 17 | import com.cnlive.media.ui.adapter.MediaAdapter; |
| 18 | import com.cnlive.media.utils.observable.SelectStateUpdateObservable; | 18 | import com.cnlive.media.utils.observable.SelectStateUpdateObservable; |
lib_media/src/main/java/com/cnlive/media/ui/fragment/MediaPreviewFragment.java
| @@ -11,7 +11,7 @@ import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | @@ -11,7 +11,7 @@ import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | ||
| 11 | import com.cnlive.media.R; | 11 | import com.cnlive.media.R; |
| 12 | import com.cnlive.media.frame.presenter.MediaPreviewPresenter; | 12 | import com.cnlive.media.frame.presenter.MediaPreviewPresenter; |
| 13 | import com.cnlive.media.frame.view.MediaPreviewView; | 13 | import com.cnlive.media.frame.view.MediaPreviewView; |
| 14 | -import com.cnlive.media.meidia.entity.Media; | 14 | +import com.cnlive.media.media.entity.Media; |
| 15 | import com.cnlive.media.ui.activity.MediaActivity; | 15 | import com.cnlive.media.ui.activity.MediaActivity; |
| 16 | import com.cnlive.media.ui.adapter.MediaPreviewAdapter; | 16 | import com.cnlive.media.ui.adapter.MediaPreviewAdapter; |
| 17 | import com.cnlive.media.databinding.FragmentPreviewBinding; | 17 | import com.cnlive.media.databinding.FragmentPreviewBinding; |
lib_media/src/main/java/com/cnlive/media/ui/fragment/RecordFragment.java
0 → 100644
| 1 | +package com.cnlive.media.ui.fragment; | ||
| 2 | + | ||
| 3 | +import android.graphics.Bitmap; | ||
| 4 | +import android.os.Bundle; | ||
| 5 | +import android.text.TextUtils; | ||
| 6 | +import android.view.View; | ||
| 7 | + | ||
| 8 | +import androidx.activity.OnBackPressedCallback; | ||
| 9 | +import androidx.annotation.Nullable; | ||
| 10 | + | ||
| 11 | +import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | ||
| 12 | +import com.cnlive.libs.base.util.DoublePressed; | ||
| 13 | +import com.cnlive.media.R; | ||
| 14 | +import com.cnlive.media.databinding.FragmentRecordBinding; | ||
| 15 | +import com.cnlive.media.frame.presenter.RecordFragmentPresenter; | ||
| 16 | +import com.cnlive.media.frame.view.RecordFragmentView; | ||
| 17 | +import com.cnlive.media.ui.widget.record.observable.RecordCameraViewObservable; | ||
| 18 | +import com.qiniu.pili.droid.shortvideo.PLCaptureFrameListener; | ||
| 19 | +import com.qiniu.pili.droid.shortvideo.PLShortVideoRecorder; | ||
| 20 | +import com.qiniu.pili.droid.shortvideo.PLVideoFrame; | ||
| 21 | +import com.qiniu.pili.droid.shortvideo.PLVideoSaveListener; | ||
| 22 | + | ||
| 23 | +import java.util.Observable; | ||
| 24 | +import java.util.Observer; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * 作 者 : wkq | ||
| 28 | + * <p> | ||
| 29 | + * 时 间 : 2020/10/29 10:04 | ||
| 30 | + * <p> | ||
| 31 | + * 名 字 : RecordFragment | ||
| 32 | + * <p> | ||
| 33 | + * 简 介 : 录制操作页面 | ||
| 34 | + */ | ||
| 35 | +public class RecordFragment extends MvpBindingFragment<RecordFragmentView, RecordFragmentPresenter, Object, FragmentRecordBinding> implements Observer { | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + public static RecordFragment newInstance() { | ||
| 39 | + | ||
| 40 | + RecordFragment fragment = new RecordFragment(); | ||
| 41 | + Bundle bundle = new Bundle(); | ||
| 42 | + fragment.setArguments(bundle); | ||
| 43 | + return fragment; | ||
| 44 | + | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + // 处理 返回事件的监听 | ||
| 48 | + public OnBackPressedCallback callback = new OnBackPressedCallback(true) { | ||
| 49 | + @Override | ||
| 50 | + public void handleOnBackPressed() { | ||
| 51 | + callback.setEnabled(false); | ||
| 52 | + requireActivity().getOnBackPressedDispatcher().onBackPressed(); | ||
| 53 | + } | ||
| 54 | + }; | ||
| 55 | + | ||
| 56 | + public PLShortVideoRecorder plShortVideoRecorder; | ||
| 57 | + public boolean isFlash; | ||
| 58 | + //准备就绪 | ||
| 59 | + public boolean isReady; | ||
| 60 | + //录制中 | ||
| 61 | + public boolean isRecordIng; | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + protected int getLayoutId() { | ||
| 65 | + return R.layout.fragment_record; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
| 70 | + super.onViewCreated(view, savedInstanceState); | ||
| 71 | + RecordCameraViewObservable.newInstance().addObserver(this); | ||
| 72 | + if (getMvpView() != null) getMvpView().initView(); | ||
| 73 | + requireActivity().getOnBackPressedDispatcher().addCallback(this, callback); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + @Override | ||
| 78 | + public void onResume() { | ||
| 79 | + super.onResume(); | ||
| 80 | + if (isFlash && getMvpView() != null) getMvpView().processFlash(isFlash); | ||
| 81 | + if (plShortVideoRecorder != null) plShortVideoRecorder.resume(); | ||
| 82 | + | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Override | ||
| 86 | + public void onPause() { | ||
| 87 | + super.onPause(); | ||
| 88 | + isRecordIng = false; | ||
| 89 | + if (plShortVideoRecorder != null) plShortVideoRecorder.pause(); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public void onDestroy() { | ||
| 94 | + super.onDestroy(); | ||
| 95 | + RecordCameraViewObservable.newInstance().deleteObserver(this); | ||
| 96 | + if (plShortVideoRecorder != null) plShortVideoRecorder.destroy(); | ||
| 97 | + | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + | ||
| 101 | + @Override | ||
| 102 | + public void update(Observable o, Object arg) { | ||
| 103 | + if (o instanceof RecordCameraViewObservable) { | ||
| 104 | + int state = (int) arg; | ||
| 105 | + if (plShortVideoRecorder == null || getMvpView() == null) return; | ||
| 106 | + //闪光灯 | ||
| 107 | + if (state == RecordCameraViewObservable.CLICK_FLASH) { | ||
| 108 | + if (isRecordIng) { | ||
| 109 | + getMvpView().showMesage("录制中..."); | ||
| 110 | + } else { | ||
| 111 | + if (plShortVideoRecorder.isFlashSupport()) { | ||
| 112 | + isFlash = (!isFlash); | ||
| 113 | + plShortVideoRecorder.setFlashEnabled(isFlash); | ||
| 114 | + getMvpView().processFlash(isFlash); | ||
| 115 | + } else { | ||
| 116 | + isFlash = false; | ||
| 117 | + getMvpView().processFlash(false); | ||
| 118 | + getMvpView().showMesage("暂不支持闪光灯"); | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + } else if (state == RecordCameraViewObservable.CLICK_SWITCH) { | ||
| 123 | + if (isRecordIng) { | ||
| 124 | + //设置前后摄像头 | ||
| 125 | + getMvpView().showMesage("录制中..."); | ||
| 126 | + | ||
| 127 | + } else { | ||
| 128 | + if (DoublePressed.onDoublePressed()) return; | ||
| 129 | + plShortVideoRecorder.switchCamera(); | ||
| 130 | + } | ||
| 131 | + } else if (state == RecordCameraViewObservable.CLICK_FINISH) { | ||
| 132 | + requireActivity().getOnBackPressedDispatcher().onBackPressed(); | ||
| 133 | + } else if (state == RecordCameraViewObservable.CLICK_TAKE) { | ||
| 134 | + //拍照 | ||
| 135 | + if (isReady) { | ||
| 136 | + plShortVideoRecorder.captureFrame(new PLCaptureFrameListener() { | ||
| 137 | + @Override | ||
| 138 | + public void onFrameCaptured(PLVideoFrame plVideoFrame) { | ||
| 139 | + Bitmap plbitMap = plVideoFrame.toBitmap(); | ||
| 140 | + | ||
| 141 | + if (plbitMap != null && plbitMap.getByteCount() > 0) { | ||
| 142 | + getMvpView().getActivity().showPreViewImg(plbitMap); | ||
| 143 | + } else { | ||
| 144 | + getMvpView().showMesage("图片拍摄异常"); | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + }); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + | ||
| 151 | + } else if (state == RecordCameraViewObservable.CLICK_RECODE_START) { | ||
| 152 | + //视频录制开始 | ||
| 153 | + if (isReady) { | ||
| 154 | + isRecordIng = true; | ||
| 155 | + plShortVideoRecorder.deleteLastSection(); | ||
| 156 | + plShortVideoRecorder.beginSection(); | ||
| 157 | + } else { | ||
| 158 | + isRecordIng = false; | ||
| 159 | + getMvpView().showMesage("相机还未准备完成,请稍后"); | ||
| 160 | + } | ||
| 161 | + } else if (state == RecordCameraViewObservable.CLICK_RECODE_FINISH) { | ||
| 162 | + //录制完成 | ||
| 163 | + plShortVideoRecorder.endSection(); | ||
| 164 | + plShortVideoRecorder.concatSections(new PLVideoSaveListener() { | ||
| 165 | + //视频保存完成 | ||
| 166 | + @Override | ||
| 167 | + public void onSaveVideoSuccess(String s) { | ||
| 168 | + if (!TextUtils.isEmpty(s)) { | ||
| 169 | + isRecordIng = false; | ||
| 170 | + getMvpView().getActivity().showVideo(s); | ||
| 171 | + } else { | ||
| 172 | + getMvpView().showMesage("视频录制异常"); | ||
| 173 | + } | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + @Override | ||
| 177 | + public void onSaveVideoFailed(int i) { | ||
| 178 | + isRecordIng = false; | ||
| 179 | + if (getMvpView() != null) getMvpView().showMesage("视频录制失败"); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + @Override | ||
| 183 | + public void onSaveVideoCanceled() { | ||
| 184 | + | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + @Override | ||
| 188 | + public void onProgressUpdate(float v) { | ||
| 189 | + | ||
| 190 | + } | ||
| 191 | + }); | ||
| 192 | + | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | +} |
lib_media/src/main/java/com/cnlive/media/utils/GlideCacheUtil.java
| @@ -23,7 +23,7 @@ import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory; | @@ -23,7 +23,7 @@ import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory; | ||
| 23 | import com.bumptech.glide.request.RequestListener; | 23 | import com.bumptech.glide.request.RequestListener; |
| 24 | import com.bumptech.glide.request.RequestOptions; | 24 | import com.bumptech.glide.request.RequestOptions; |
| 25 | import com.bumptech.glide.request.target.Target; | 25 | import com.bumptech.glide.request.target.Target; |
| 26 | -import com.cnlive.media.meidia.entity.Media; | 26 | +import com.cnlive.media.media.entity.Media; |
| 27 | import com.cnlive.media.R; | 27 | import com.cnlive.media.R; |
| 28 | 28 | ||
| 29 | import java.io.File; | 29 | import java.io.File; |
lib_media/src/main/java/com/cnlive/media/utils/MediaUtils.java
| 1 | package com.cnlive.media.utils; | 1 | package com.cnlive.media.utils; |
| 2 | 2 | ||
| 3 | -import com.cnlive.media.meidia.entity.Media; | 3 | +import com.cnlive.media.media.entity.Media; |
| 4 | 4 | ||
| 5 | public class MediaUtils { | 5 | public class MediaUtils { |
| 6 | private final static String MIME_TYPE_PNG = "image/png"; | 6 | private final static String MIME_TYPE_PNG = "image/png"; |
lib_media/src/main/java/com/cnlive/media/utils/MyGLRenderer.java
0 → 100644
| 1 | +package com.cnlive.media.utils; | ||
| 2 | + | ||
| 3 | +import android.opengl.EGLConfig; | ||
| 4 | +import android.opengl.GLSurfaceView; | ||
| 5 | + | ||
| 6 | +import javax.microedition.khronos.opengles.GL10; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 作 者 : wkq | ||
| 10 | + * <p> | ||
| 11 | + * 时 间 : 2020/10/28 17:16 | ||
| 12 | + * <p> | ||
| 13 | + * 名 字 : MyGLRenderer | ||
| 14 | + * <p> | ||
| 15 | + * 简 介 : | ||
| 16 | + */ | ||
| 17 | +public class MyGLRenderer implements GLSurfaceView.Renderer { | ||
| 18 | + public void onSurfaceCreated(GL10 gl, EGLConfig config) | ||
| 19 | + { | ||
| 20 | + gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + @Override | ||
| 24 | + public void onSurfaceCreated(GL10 gl, javax.microedition.khronos.egl.EGLConfig config) { | ||
| 25 | + | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public void onSurfaceChanged(GL10 gl, int w, int h) { | ||
| 29 | + gl.glViewport(0, 0, w, h); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public void onDrawFrame(GL10 gl) { | ||
| 33 | + gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); | ||
| 34 | + } | ||
| 35 | +} | ||
| 0 | \ No newline at end of file | 36 | \ No newline at end of file |
lib_media/src/main/java/com/cnlive/media/utils/QiniuVideoUtil.java
0 → 100644
| 1 | +package com.cnlive.media.utils; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | + | ||
| 5 | +import com.qiniu.pili.droid.shortvideo.PLShortVideoEnv; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 作 者 : wkq | ||
| 9 | + * <p> | ||
| 10 | + * 时 间 : 2020/10/29 9:46 | ||
| 11 | + * <p> | ||
| 12 | + * 名 字 : QiniuVideoUtil | ||
| 13 | + * <p> | ||
| 14 | + * 简 介 : 七牛 初始化 | ||
| 15 | + */ | ||
| 16 | +public class QiniuVideoUtil { | ||
| 17 | + /** | ||
| 18 | + * 初始化七牛sdk | ||
| 19 | + * @param context | ||
| 20 | + */ | ||
| 21 | + public static void initVideo(Context context) { | ||
| 22 | + PLShortVideoEnv.init(context.getApplicationContext()); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 检查授权状态 | ||
| 27 | + * @param context | ||
| 28 | + * @param listener | ||
| 29 | + */ | ||
| 30 | + public static void chcekInitState(Context context, QiniuVideoInitListener listener) { | ||
| 31 | + PLShortVideoEnv.checkAuthentication(context, i -> { | ||
| 32 | + if (i==1){ | ||
| 33 | + listener.isInitState(true); | ||
| 34 | + }else { | ||
| 35 | + listener.isInitState(false); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + }); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public interface QiniuVideoInitListener{ | ||
| 42 | + void isInitState(boolean isInit); | ||
| 43 | + } | ||
| 44 | +} |
lib_media/src/main/java/com/cnlive/media/utils/observable/MediaAddObservable.java
lib_media/src/main/java/com/cnlive/media/utils/observable/MediaOpenInfo.java
lib_media/src/main/java/com/cnlive/media/utils/observable/MediaPageSelectStateObservable.java
lib_media/src/main/java/com/cnlive/media/utils/observable/MediaSelectStateObservable.java
lib_media/src/main/java/com/cnlive/media/utils/observable/MeidaResultObservable.java
lib_media/src/main/java/com/cnlive/media/utils/observable/SelectStateUpdateObservable.java
lib_media/src/main/res/layout/activity_record.xml
| @@ -10,27 +10,7 @@ | @@ -10,27 +10,7 @@ | ||
| 10 | android:id="@+id/pre_frame" | 10 | android:id="@+id/pre_frame" |
| 11 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
| 12 | android:layout_height="match_parent" | 12 | android:layout_height="match_parent" |
| 13 | - android:background="@color/transparent" | ||
| 14 | - android:visibility="gone" /> | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - <android.opengl.GLSurfaceView | ||
| 18 | - android:id="@+id/g_sf" | ||
| 19 | - android:layout_width="match_parent" | ||
| 20 | - android:layout_height="match_parent" /> | ||
| 21 | - | ||
| 22 | - <com.cnlive.media.ui.widget.record.FoucsView | ||
| 23 | - android:id="@+id/fv" | ||
| 24 | - android:layout_width="wrap_content" | ||
| 25 | - android:layout_height="wrap_content" | ||
| 26 | - android:layout_centerInParent="true" | ||
| 27 | - android:visibility="gone" /> | ||
| 28 | - | ||
| 29 | - <com.cnlive.media.ui.widget.record.RecordCameraView | ||
| 30 | - android:id="@+id/rc_control" | ||
| 31 | - android:layout_width="match_parent" | ||
| 32 | - android:layout_height="match_parent" /> | ||
| 33 | - | 13 | + android:background="@color/transparent" /> |
| 34 | 14 | ||
| 35 | </RelativeLayout> | 15 | </RelativeLayout> |
| 36 | </layout> | 16 | </layout> |
| 37 | \ No newline at end of file | 17 | \ No newline at end of file |
lib_media/src/main/res/layout/fragment_record.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout> | ||
| 3 | + | ||
| 4 | + | ||
| 5 | + <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:background="@color/transparent" | ||
| 8 | + android:layout_height="match_parent"> | ||
| 9 | + | ||
| 10 | + <android.opengl.GLSurfaceView | ||
| 11 | + android:id="@+id/g_sf" | ||
| 12 | + android:layout_width="match_parent" | ||
| 13 | + android:layout_height="match_parent" /> | ||
| 14 | + | ||
| 15 | + <com.cnlive.media.ui.widget.record.FoucsView | ||
| 16 | + android:id="@+id/fv" | ||
| 17 | + android:layout_width="wrap_content" | ||
| 18 | + android:layout_height="wrap_content" | ||
| 19 | + android:layout_centerInParent="true" | ||
| 20 | + android:visibility="gone" /> | ||
| 21 | + | ||
| 22 | + <com.cnlive.media.ui.widget.record.RecordCameraView | ||
| 23 | + android:id="@+id/rc_control" | ||
| 24 | + android:layout_width="match_parent" | ||
| 25 | + android:layout_height="match_parent" /> | ||
| 26 | + | ||
| 27 | + </RelativeLayout> | ||
| 28 | +</layout> | ||
| 0 | \ No newline at end of file | 29 | \ No newline at end of file |
lib_media/src/main/res/layout/fragment_record_preview.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <layout xmlns:app="http://schemas.android.com/apk/res-auto"> | 2 | <layout xmlns:app="http://schemas.android.com/apk/res-auto"> |
| 3 | + | ||
| 3 | <data> | 4 | <data> |
| 4 | - <import type="android.view.View.OnClickListener"/> | 5 | + |
| 6 | + <import type="android.view.View.OnClickListener" /> | ||
| 7 | + | ||
| 5 | <variable | 8 | <variable |
| 6 | name="onClick" | 9 | name="onClick" |
| 7 | type="OnClickListener" /> | 10 | type="OnClickListener" /> |
| @@ -9,35 +12,37 @@ | @@ -9,35 +12,37 @@ | ||
| 9 | 12 | ||
| 10 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 13 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 11 | android:layout_width="match_parent" | 14 | android:layout_width="match_parent" |
| 12 | - android:layout_height="match_parent"> | 15 | + android:layout_height="match_parent" |
| 16 | + android:background="@color/transparent"> | ||
| 13 | 17 | ||
| 14 | 18 | ||
| 15 | <com.github.chrisbanes.photoview.PhotoView | 19 | <com.github.chrisbanes.photoview.PhotoView |
| 16 | - android:visibility="gone" | ||
| 17 | android:id="@+id/iv_pre" | 20 | android:id="@+id/iv_pre" |
| 18 | android:layout_width="match_parent" | 21 | android:layout_width="match_parent" |
| 19 | android:layout_height="match_parent" | 22 | android:layout_height="match_parent" |
| 20 | - android:scaleType="centerCrop" /> | 23 | + android:scaleType="centerCrop" |
| 24 | + android:visibility="gone" /> | ||
| 21 | 25 | ||
| 22 | 26 | ||
| 23 | <FrameLayout | 27 | <FrameLayout |
| 24 | - android:visibility="gone" | ||
| 25 | android:id="@+id/fl_video" | 28 | android:id="@+id/fl_video" |
| 26 | android:layout_width="match_parent" | 29 | android:layout_width="match_parent" |
| 27 | android:layout_height="wrap_content" | 30 | android:layout_height="wrap_content" |
| 28 | - android:layout_centerInParent="true"> | 31 | + android:layout_centerInParent="true" |
| 32 | + android:visibility="gone"> | ||
| 33 | + | ||
| 29 | <android.opengl.GLSurfaceView | 34 | <android.opengl.GLSurfaceView |
| 30 | - android:onClick="@{onClick}" | ||
| 31 | android:id="@+id/gv_video" | 35 | android:id="@+id/gv_video" |
| 32 | android:layout_width="match_parent" | 36 | android:layout_width="match_parent" |
| 33 | - android:layout_height="match_parent" /> | 37 | + android:layout_height="match_parent" |
| 38 | + android:onClick="@{onClick}" /> | ||
| 34 | 39 | ||
| 35 | <ImageView | 40 | <ImageView |
| 36 | - android:onClick="@{onClick}" | ||
| 37 | android:id="@+id/play_control_iv" | 41 | android:id="@+id/play_control_iv" |
| 38 | android:layout_width="wrap_content" | 42 | android:layout_width="wrap_content" |
| 39 | android:layout_height="wrap_content" | 43 | android:layout_height="wrap_content" |
| 40 | android:layout_gravity="center" | 44 | android:layout_gravity="center" |
| 45 | + android:onClick="@{onClick}" | ||
| 41 | android:src="@drawable/iv_pre_play" | 46 | android:src="@drawable/iv_pre_play" |
| 42 | android:visibility="gone" /> | 47 | android:visibility="gone" /> |
| 43 | 48 | ||
| @@ -51,24 +56,24 @@ | @@ -51,24 +56,24 @@ | ||
| 51 | android:layout_marginBottom="40dp"> | 56 | android:layout_marginBottom="40dp"> |
| 52 | 57 | ||
| 53 | <com.cnlive.media.ui.widget.record.TypeButton | 58 | <com.cnlive.media.ui.widget.record.TypeButton |
| 54 | - android:onClick="@{onClick}" | ||
| 55 | android:id="@+id/tb_cancel" | 59 | android:id="@+id/tb_cancel" |
| 56 | android:layout_width="wrap_content" | 60 | android:layout_width="wrap_content" |
| 57 | android:layout_height="wrap_content" | 61 | android:layout_height="wrap_content" |
| 58 | android:layout_alignParentLeft="true" | 62 | android:layout_alignParentLeft="true" |
| 59 | android:layout_centerVertical="true" | 63 | android:layout_centerVertical="true" |
| 60 | android:layout_marginLeft="30dp" | 64 | android:layout_marginLeft="30dp" |
| 65 | + android:onClick="@{onClick}" | ||
| 61 | app:typeBg="@drawable/fb_chongpai" | 66 | app:typeBg="@drawable/fb_chongpai" |
| 62 | app:typeSize="35dp" /> | 67 | app:typeSize="35dp" /> |
| 63 | 68 | ||
| 64 | <com.cnlive.media.ui.widget.record.TypeButton | 69 | <com.cnlive.media.ui.widget.record.TypeButton |
| 65 | - android:onClick="@{onClick}" | ||
| 66 | android:id="@+id/tb_ok" | 70 | android:id="@+id/tb_ok" |
| 67 | android:layout_width="wrap_content" | 71 | android:layout_width="wrap_content" |
| 68 | android:layout_height="wrap_content" | 72 | android:layout_height="wrap_content" |
| 69 | android:layout_alignParentRight="true" | 73 | android:layout_alignParentRight="true" |
| 70 | android:layout_centerVertical="true" | 74 | android:layout_centerVertical="true" |
| 71 | android:layout_marginRight="30dp" | 75 | android:layout_marginRight="30dp" |
| 76 | + android:onClick="@{onClick}" | ||
| 72 | app:typeBg="@drawable/fb_wancheng" | 77 | app:typeBg="@drawable/fb_wancheng" |
| 73 | app:typeSize="35dp" /> | 78 | app:typeSize="35dp" /> |
| 74 | </RelativeLayout> | 79 | </RelativeLayout> |