Feature: record video when camera previewing

pull/221/head
xufuji456 2 years ago
parent a30527f8fc
commit 3ed37dba16
  1. 10
      CameraFilter/src/main/java/com/frank/camerafilter/widget/BeautyCameraView.java
  2. 4
      CameraFilter/src/main/java/com/frank/camerafilter/widget/CameraRender.java
  3. 16
      app/src/main/java/com/frank/ffmpeg/activity/CameraFilterActivity.kt
  4. BIN
      app/src/main/res/drawable-xhdpi/ic_camera_filter.png
  5. BIN
      app/src/main/res/drawable-xhdpi/ic_video_record.png
  6. 29
      app/src/main/res/layout/activity_camera_filter.xml

@ -40,11 +40,21 @@ public class BeautyCameraView extends GLSurfaceView {
}
public void setFilter(BeautyFilterType type) {
if (mCameraRender == null)
return;
mCameraRender.setFilter(type);
}
public void setRecording(boolean isRecording) {
if (mCameraRender == null)
return;
mCameraRender.setRecording(isRecording);
}
public boolean isRecording() {
if (mCameraRender == null)
return false;
return mCameraRender.isRecording();
}
}

@ -216,6 +216,10 @@ public class CameraRender implements GLSurfaceView.Renderer, SurfaceTexture.OnFr
recordEnable = isRecording;
}
public boolean isRecording() {
return recordEnable;
}
public void setFilter(final BeautyFilterType type) {
mCameraView.queueEvent(new Runnable() {
@Override

@ -1,10 +1,8 @@
package com.frank.ffmpeg.activity
import android.os.Bundle
import android.view.SurfaceView
import android.view.View
import com.frank.camerafilter.widget.BeautyCameraView
import com.frank.ffmpeg.FFMediaPlayer
import com.frank.ffmpeg.R
class CameraFilterActivity : BaseActivity() {
@ -22,10 +20,22 @@ class CameraFilterActivity : BaseActivity() {
fun initView() {
cameraView = getView(R.id.surface_camera_filter)
initViewsWithClick(R.id.btn_video_recorder)
initViewsWithClick(R.id.btn_camera_filter)
}
override fun onViewClick(view: View) {
if (view.id == R.id.btn_video_recorder) {
val isRecording = cameraView!!.isRecording
cameraView!!.isRecording = !isRecording
if (!isRecording) {
showToast("start recording...")
} else {
showToast("stop recording...")
}
} else if (view.id == R.id.btn_camera_filter) {
}
}
override fun onSelectedFile(filePath: String) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

@ -4,8 +4,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.CameraFilterActivity"
android:layout_marginTop="66dp"
android:layout_marginBottom="66dp">
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp">
<com.frank.camerafilter.widget.BeautyCameraView
android:id="@+id/surface_camera_filter"
@ -13,4 +13,29 @@
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="33dp"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/btn_video_recorder"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:src="@drawable/ic_video_record"
android:background="?android:attr/selectableItemBackground"/>
<ImageView
android:id="@+id/btn_camera_filter"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginStart="66dp"
android:src="@drawable/ic_camera_filter"
android:background="?android:attr/selectableItemBackground"/>
</LinearLayout>
</RelativeLayout>
Loading…
Cancel
Save