diff --git a/Video-Transformers-Java/app/build.gradle b/Video-Transformers-Java/app/build.gradle index 8c5a0480..6415ba33 100644 --- a/Video-Transformers-Java/app/build.gradle +++ b/Video-Transformers-Java/app/build.gradle @@ -32,7 +32,7 @@ android { dependencies { // Dependency versions are defined in the ../../commons.gradle file - implementation "com.opentok.android:opentok-android-sdk:2.25.2" + implementation "com.opentok.android:opentok-android-sdk:2.27.0" implementation "androidx.appcompat:appcompat:${extAppCompatVersion}" implementation "pub.devrel:easypermissions:${extEasyPermissionsVersion}" implementation "androidx.constraintlayout:constraintlayout:${extConstraintLyoutVersion}" diff --git a/Video-Transformers-Java/app/src/main/AndroidManifest.xml b/Video-Transformers-Java/app/src/main/AndroidManifest.xml index 72b83861..62cbc064 100644 --- a/Video-Transformers-Java/app/src/main/AndroidManifest.xml +++ b/Video-Transformers-Java/app/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ + diff --git a/Video-Transformers-Java/app/src/main/java/com/tokbox/sample/videotransformers/MainActivity.java b/Video-Transformers-Java/app/src/main/java/com/tokbox/sample/videotransformers/MainActivity.java index fbc13649..f6849e29 100644 --- a/Video-Transformers-Java/app/src/main/java/com/tokbox/sample/videotransformers/MainActivity.java +++ b/Video-Transformers-Java/app/src/main/java/com/tokbox/sample/videotransformers/MainActivity.java @@ -2,6 +2,7 @@ import android.Manifest; import android.content.Context; +import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -39,6 +40,7 @@ import retrofit2.Retrofit; import retrofit2.converter.moshi.MoshiConverterFactory; +import java.io.File; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; @@ -205,7 +207,7 @@ public void onPermissionsDenied(int requestCode, List perms) { @AfterPermissionGranted(PERMISSIONS_REQUEST_CODE) private void requestPermissions() { - String[] perms = {Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO}; + String[] perms = {Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE}; if (EasyPermissions.hasPermissions(this, perms)) { @@ -354,10 +356,25 @@ public void onTransform(BaseVideoRenderer.Frame frame){ public void SetVideoTransformers(View view) { if(!isSet) { videoTransformers.clear(); - PublisherKit.VideoTransformer backgroundBlur = publisher.new VideoTransformer("BackgroundBlur", "{\"radius\":\"High\"}"); - PublisherKit.VideoTransformer myCustomTransformer = publisher.new VideoTransformer("myTransformer", logoTransformer); - videoTransformers.add(backgroundBlur); - videoTransformers.add(myCustomTransformer); + String resourceName; + try { + resourceName = getResources().getResourceEntryName(R.drawable.beach); // Assuming "beach" is the name of the drawable resource + } catch (Resources.NotFoundException e) { + return; // Return if the resource ID is not found + } + + File imageFile = new File(getBaseContext().getFilesDir(), resourceName + ".jpeg"); + + //ArrayList videoTransformers = new ArrayList<>(); + PublisherKit.VideoTransformer backgroundReplacement = publisher.new VideoTransformer( + "BackgroundReplacement", + "{\"image_file_path\":\"" + imageFile.getAbsolutePath() + "\"}" + ); + videoTransformers.add(backgroundReplacement); + //PublisherKit.VideoTransformer backgroundBlur = publisher.new VideoTransformer("BackgroundBlur", "{\"radius\":\"High\"}"); + //PublisherKit.VideoTransformer myCustomTransformer = publisher.new VideoTransformer("myTransformer", logoTransformer); + //videoTransformers.add(backgroundBlur); + //videoTransformers.add(myCustomTransformer); publisher.setVideoTransformers(videoTransformers); isSet = true; buttonVideoTransformers.setText("Reset"); diff --git a/Video-Transformers-Java/app/src/main/res/drawable/beach.jpeg b/Video-Transformers-Java/app/src/main/res/drawable/beach.jpeg new file mode 100644 index 00000000..192af6d0 Binary files /dev/null and b/Video-Transformers-Java/app/src/main/res/drawable/beach.jpeg differ