调整短视频录制结束后的通信方式

TempBranch
Matthew 9 months ago
parent 0cd8952824
commit c381da7947

@ -230,12 +230,12 @@ public class BridgeActivity extends AppCompatActivity {
Intent recordingIntent = MicroPhotoService.makeRecordingIntent(getApplicationContext(),
false, cameraId, videoId, duration, width, height, quality, orientation,
leftTopOsd, rightTopOsd, rightBottomOsd, leftBottomOsd);
leftTopOsd, rightTopOsd, rightBottomOsd, leftBottomOsd, null);
mVideoFilePath = path;
mAutoClose = false;
recordingIntent.putExtra("ActivityResult", true);
recordingIntent.putExtra("resultType", 1);
startActivityForResult(recordingIntent, REQUEST_CODE_RECORDING);
}
}

@ -345,9 +345,9 @@ public class BridgeProvider extends ContentProvider {
Intent recordingIntent = MicroPhotoService.makeRecordingIntent(context,
false, cameraId, videoId, duration, width, height, quality, orientation,
leftTopOsd, rightTopOsd, rightBottomOsd, leftBottomOsd);
leftTopOsd, rightTopOsd, rightBottomOsd, leftBottomOsd, path);
recordingIntent.putExtra("ActivityResult", false);
recordingIntent.putExtra("resultType", 0);
context.startActivity(recordingIntent);
return 1;

@ -534,23 +534,28 @@ public class MicroPhotoService extends Service {
registerPhotoTimer(getApplicationContext(), scheduleTime, scheduleTime, timeout, schedules);
}
// From Native
public void startRecording(boolean photoOrVideo, int cameraId, long videoId, int duration, int width, int height, int quality, int orientation, String leftTopOsd, String rightTopOsd, String rightBottomOsd, String leftBottomOsd) {
Context context = getApplicationContext();
Intent intent = makeRecordingIntent(context, photoOrVideo, cameraId, videoId, duration, width, height, quality, orientation,
leftTopOsd, rightTopOsd, rightBottomOsd, leftBottomOsd);
leftTopOsd, rightTopOsd, rightBottomOsd, leftBottomOsd, null);
intent.putExtra("resultType", 2);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
public static Intent makeRecordingIntent(Context context, boolean photoOrVideo, int cameraId, long videoId, int duration, int width, int height, int quality, int orientation, String leftTopOsd, String rightTopOsd, String rightBottomOsd, String leftBottomOsd) {
public static Intent makeRecordingIntent(Context context, boolean photoOrVideo, int cameraId, long videoId, int duration, int width, int height, int quality, int orientation, String leftTopOsd, String rightTopOsd, String rightBottomOsd, String leftBottomOsd, String path) {
// Intent intent = new Intent(this, VideoActivity.class);
Intent intent = photoOrVideo ? new Intent(context, RawActivity.class) : new Intent(context, Camera2VideoActivity.class);
intent.putExtra("cameraId", cameraId);
intent.putExtra("videoId", videoId);
if (!TextUtils.isEmpty(path)) {
intent.putExtra("path", path);
}
intent.putExtra("duration", duration);
intent.putExtra("width", width);
intent.putExtra("height", height);

@ -60,6 +60,10 @@ public class Camera2VideoActivity extends AppCompatActivity {
public static final String ACTION_FINISH = "com.xypower.mvapp.ACT_FINISH";
public static final String ACTION_MP_VIDEO_FINISHED = "com.xypower.mpapp.ACT_V_FINISHED";
public static final int RESULT_TYPE_NONE = 0;
public static final int RESULT_TYPE_ACTIVITY_RESULT = 1;
public static final int RESULT_TYPE_BROADCAST = 2;
public final static int REQUEST_CODE_RECORDING = 2;
private static final int DEFAULT_FONT_SIZE = 32;
@ -104,7 +108,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
private int mTimeMask = 0;
private int mStatusBarHeight = -1;
private boolean mActivityResult = false;
private int mResultType = RESULT_TYPE_NONE;
private static class OSD_ITEM
{
@ -257,7 +261,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
mOSDRightTop = intent.getStringExtra("rightTopOsd");
mOSDMargin = intent.getIntExtra("margin", 12);
mActivityResult = intent.getBooleanExtra("ActivityResult", false);
mResultType = intent.getIntExtra("resultType", RESULT_TYPE_BROADCAST);
mCameraWidth = mVideoWidth;
mCameraHeight = mVideoHeight;
@ -330,7 +334,9 @@ public class Camera2VideoActivity extends AppCompatActivity {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mNextVideoAbsolutePath = getVideoFilePath();
if (TextUtils.isEmpty(mNextVideoAbsolutePath)) {
mNextVideoAbsolutePath = getVideoFilePath();
}
if (mGPUCameraRecorder != null) {
mGPUCameraRecorder.start(mNextVideoAbsolutePath);
} else {
@ -735,7 +741,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
private void setUpCamera() {
setUpCameraView();
if (mNextVideoAbsolutePath == null || mNextVideoAbsolutePath.isEmpty()) {
if (TextUtils.isEmpty(mNextVideoAbsolutePath)) {
mNextVideoAbsolutePath = getVideoFilePath(this);
}
@ -832,6 +838,10 @@ public class Camera2VideoActivity extends AppCompatActivity {
return;
}
if (mResultType == RESULT_TYPE_NONE) {
return;
}
Context context = getApplicationContext();
String receiverName = MicroPhotoService.AlarmReceiver.class.getName();
String packageName = context.getPackageName();
@ -845,7 +855,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
// intent.setComponent(new ComponentName(packageName, receiverName));
if (mActivityResult) {
if (mResultType == RESULT_TYPE_ACTIVITY_RESULT) {
setResult(RESULT_OK, intent);
} else {
// Log.i(TAG, "Notify recording videoId=" + Long.toString(mVideoId) + " " + path);

Loading…
Cancel
Save