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

nx2024TEMP
Matthew 9 months ago
parent d593ef34bc
commit 9704980db5

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

@ -345,9 +345,9 @@ public class BridgeProvider extends ContentProvider {
Intent recordingIntent = MicroPhotoService.makeRecordingIntent(context, Intent recordingIntent = MicroPhotoService.makeRecordingIntent(context,
false, cameraId, videoId, duration, width, height, quality, orientation, 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); context.startActivity(recordingIntent);
return 1; return 1;

@ -534,23 +534,28 @@ public class MicroPhotoService extends Service {
registerPhotoTimer(getApplicationContext(), scheduleTime, scheduleTime, timeout, schedules); 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) { 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(); Context context = getApplicationContext();
Intent intent = makeRecordingIntent(context, photoOrVideo, cameraId, videoId, duration, width, height, quality, orientation, 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); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent); 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 = new Intent(this, VideoActivity.class);
Intent intent = photoOrVideo ? new Intent(context, RawActivity.class) : new Intent(context, Camera2VideoActivity.class); Intent intent = photoOrVideo ? new Intent(context, RawActivity.class) : new Intent(context, Camera2VideoActivity.class);
intent.putExtra("cameraId", cameraId); intent.putExtra("cameraId", cameraId);
intent.putExtra("videoId", videoId); intent.putExtra("videoId", videoId);
if (!TextUtils.isEmpty(path)) {
intent.putExtra("path", path);
}
intent.putExtra("duration", duration); intent.putExtra("duration", duration);
intent.putExtra("width", width); intent.putExtra("width", width);
intent.putExtra("height", height); 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_FINISH = "com.xypower.mvapp.ACT_FINISH";
public static final String ACTION_MP_VIDEO_FINISHED = "com.xypower.mpapp.ACT_V_FINISHED"; 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; public final static int REQUEST_CODE_RECORDING = 2;
private static final int DEFAULT_FONT_SIZE = 32; private static final int DEFAULT_FONT_SIZE = 32;
@ -104,7 +108,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
private int mTimeMask = 0; private int mTimeMask = 0;
private int mStatusBarHeight = -1; private int mStatusBarHeight = -1;
private boolean mActivityResult = false; private int mResultType = RESULT_TYPE_NONE;
private static class OSD_ITEM private static class OSD_ITEM
{ {
@ -257,7 +261,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
mOSDRightTop = intent.getStringExtra("rightTopOsd"); mOSDRightTop = intent.getStringExtra("rightTopOsd");
mOSDMargin = intent.getIntExtra("margin", 12); mOSDMargin = intent.getIntExtra("margin", 12);
mActivityResult = intent.getBooleanExtra("ActivityResult", false); mResultType = intent.getIntExtra("resultType", RESULT_TYPE_BROADCAST);
mCameraWidth = mVideoWidth; mCameraWidth = mVideoWidth;
mCameraHeight = mVideoHeight; mCameraHeight = mVideoHeight;
@ -330,7 +334,9 @@ public class Camera2VideoActivity extends AppCompatActivity {
mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
if (TextUtils.isEmpty(mNextVideoAbsolutePath)) {
mNextVideoAbsolutePath = getVideoFilePath(); mNextVideoAbsolutePath = getVideoFilePath();
}
if (mGPUCameraRecorder != null) { if (mGPUCameraRecorder != null) {
mGPUCameraRecorder.start(mNextVideoAbsolutePath); mGPUCameraRecorder.start(mNextVideoAbsolutePath);
} else { } else {
@ -735,7 +741,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
private void setUpCamera() { private void setUpCamera() {
setUpCameraView(); setUpCameraView();
if (mNextVideoAbsolutePath == null || mNextVideoAbsolutePath.isEmpty()) { if (TextUtils.isEmpty(mNextVideoAbsolutePath)) {
mNextVideoAbsolutePath = getVideoFilePath(this); mNextVideoAbsolutePath = getVideoFilePath(this);
} }
@ -832,6 +838,10 @@ public class Camera2VideoActivity extends AppCompatActivity {
return; return;
} }
if (mResultType == RESULT_TYPE_NONE) {
return;
}
Context context = getApplicationContext(); Context context = getApplicationContext();
String receiverName = MicroPhotoService.AlarmReceiver.class.getName(); String receiverName = MicroPhotoService.AlarmReceiver.class.getName();
String packageName = context.getPackageName(); String packageName = context.getPackageName();
@ -845,7 +855,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
// intent.setComponent(new ComponentName(packageName, receiverName)); // intent.setComponent(new ComponentName(packageName, receiverName));
if (mActivityResult) { if (mResultType == RESULT_TYPE_ACTIVITY_RESULT) {
setResult(RESULT_OK, intent); setResult(RESULT_OK, intent);
} else { } else {
// Log.i(TAG, "Notify recording videoId=" + Long.toString(mVideoId) + " " + path); // Log.i(TAG, "Notify recording videoId=" + Long.toString(mVideoId) + " " + path);

Loading…
Cancel
Save