Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening VE with Photo or Video on camera only #274

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.banuba.example.integrationapp.databinding.ActivityMainBinding
import com.banuba.sdk.cameraui.data.CameraConfig
import com.banuba.sdk.cameraui.data.CameraRecordingModesProvider
import com.banuba.sdk.cameraui.data.PipConfig
import com.banuba.sdk.cameraui.ui.RecordMode
import com.banuba.sdk.core.ui.ext.visible
import com.banuba.sdk.export.data.ExportResult
import com.banuba.sdk.export.utils.EXTRA_EXPORTED_SUCCESS
import com.banuba.sdk.pe.PhotoCreationActivity
import com.banuba.sdk.pe.PhotoExportResultContract
import com.banuba.sdk.ve.flow.VideoCreationActivity
import com.banuba.sdk.ve.flow.VideoExportResultContract
import org.koin.android.ext.android.inject


class MainActivity : AppCompatActivity() {
Expand Down Expand Up @@ -129,6 +133,12 @@ class MainActivity : AppCompatActivity() {
// Start Photo Editor SDK
photoEditorExportResult.launch(PhotoCreationActivity.startFromGallery(this@MainActivity))
}
binding.btnCameraVideoOnly.setOnClickListener {
startVideoEditorVideoOnCameraOnly()
}
binding.btnPhotoOnly.setOnClickListener {
startVideoEditorPhotoOnCameraOnly()
}
} else {
// ❌ Use of Video Editor is restricted. License is revoked or expired.
binding.licenseStateView.text = SampleApp.ERR_LICENSE_REVOKED
Expand Down Expand Up @@ -183,4 +193,20 @@ class MainActivity : AppCompatActivity() {
(application as? SampleApp)?.prepareVideoEditor()
videoEditorExportResult.launch(veIntent)
}

private fun startVideoEditorVideoOnCameraOnly() {
(application as? SampleApp)?.prepareVideoEditor()
val cameraRecordingModesProvider: CameraRecordingModesProvider by inject()
cameraRecordingModesProvider.availableModes = setOf(RecordMode.Video)
videoEditorExportResult.launch(VideoCreationActivity.startFromCamera(context = applicationContext))
}

private fun startVideoEditorPhotoOnCameraOnly() {
(application as? SampleApp)?.prepareVideoEditor()
val cameraRecordingModesProvider: CameraRecordingModesProvider by inject()
cameraRecordingModesProvider.availableModes = setOf(RecordMode.Photo)
val cameraConfig: CameraConfig by inject()
cameraConfig.supportsExternalMusic = false
videoEditorExportResult.launch(VideoCreationActivity.startFromCamera(context = applicationContext))
}
}
34 changes: 32 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,43 @@
android:layout_marginTop="16dp"
android:text="Open Video Editor - Trimmer"
android:textSize="11sp"
app:layout_constraintBottom_toTopOf="@+id/btnOpenPhotoEditor"
app:layout_constraintBottom_toTopOf="@+id/btnCameraVideoOnly"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnDraftsVideoEditor"
app:layout_constraintVertical_bias="0" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnCameraVideoOnly"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Open Camera Video Only"
app:backgroundTint="@android:color/holo_red_dark"
android:textSize="11sp"
app:layout_constraintBottom_toTopOf="@+id/btnPhotoOnly"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnSlideShowVideoEditorTrimmer"
app:layout_constraintVertical_bias="0" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnPhotoOnly"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Open Camera Photo Only"
app:backgroundTint="@android:color/holo_red_dark"
android:textSize="11sp"
app:layout_constraintBottom_toTopOf="@+id/btnOpenPhotoEditor"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnCameraVideoOnly"
app:layout_constraintVertical_bias="0" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnOpenPhotoEditor"
android:layout_width="240dp"
Expand All @@ -73,7 +103,7 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnSlideShowVideoEditorTrimmer"
app:layout_constraintTop_toBottomOf="@+id/btnPhotoOnly"
app:layout_constraintVertical_bias="0" />

<TextView
Expand Down