英文:
I get this error when I add it to the Video Texture View xml file(java.lang.BootstrapMethodError: Exception from call site #72 bootstrap method)
问题
I want to play local video with VideoTextureView in Twilio library. Can you help me?
package com.bariskarapelit.touchcontrol;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.twilio.video.VideoTextureView;
public class MainActivity extends AppCompatActivity {
ImageButton circleButton, likeButton, dislikeButton;
VideoTextureView videoTextureView;
int selectedImage = R.drawable.circlepng;
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
circleButton = findViewById(R.id.circle);
dislikeButton = findViewById(R.id.dislike);
likeButton = findViewById(R.id.like);
videoTextureView = findViewById(R.id.video_view_top_right);
MultiTouchControl multiTouchControl = new MultiTouchControl(frameLayout, new MultiTouchControl.ComponentView() {
@Override
public View onCreateComponent() {
ImageView image = new ImageView(frameLayout.getContext());
image.setImageResource(selectedImage);
return image;
}
});
multiTouchControl.startListener();
setupButtons();
}
private void setupButtons() {
circleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "Circle", Toast.LENGTH_LONG).show();
selectedImage = R.drawable.circlepng;
}
});
dislikeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "Dislike", Toast.LENGTH_LONG).show();
selectedImage = R.drawable.dislike;
}
});
likeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "Like", Toast.LENGTH_LONG).show();
selectedImage = R.drawable.like;
}
});
}
}
MultiTouchControl Code:
package com.bariskarapelit.touchcontrol;
import android.annotation.SuppressLint;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
public class MultiTouchControl implements View.OnTouchListener {
private ViewGroup root;
private ComponentView componentView;
private float circleSize = 100;
private int duration = 1500;
private List<Vector3> fingerTips = new ArrayList<>();
private boolean enabled = true;
public MultiTouchControl(ViewGroup root, ComponentView componentView) {
this.root = root;
this.componentView = componentView;
}
public void startListener() {
root.setOnTouchListener(this);
}
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
if (!enabled)
return false;
final int points = event.getPointerCount();
int removedPoint = -1;
final int action = event.getAction() & MotionEvent.ACTION_MASK;
if (event.getAction() == MotionEvent.ACTION_MOVE) {
fingerTips.clear();
return false;
}
if (action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_UP)
removedPoint = (action & MotionEvent.ACTION_POINTER_INDEX_MASK)
>> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
fingerTips.clear();
for (int i = 0; i < points; i++) {
int pointerID = event.getPointerId(i);
if (pointerID == MotionEvent.INVALID_POINTER_ID) {
continue;
}
if (removedPoint == i) {
continue;
}
fingerTips.add(new Vector3(event.getX(i), event.getY(i), pointerID));
}
for (Vector3 fingerTip : fingerTips) {
createCircle(fingerTip.x, fingerTip.y);
}
return true;
}
private void createCircle(float x, float y) {
if (componentView != null) {
View view = componentView.onCreateComponent();
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
view.setX(x - circleSize / 2);
view.setY(y - circleSize / 2);
params.width = (int) circleSize;
params.height = (int) circleSize;
view.setLayoutParams(params);
root.addView(view);
dieAfter(view);
}
}
private void dieAfter(final View view) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
root.removeView(view);
}
}, duration);
}
static class Vector3 {
public float x, y;
public int id;
public Vector3(float x, float y, int id) {
this.x = x;
this.y = y;
this.id = id;
}
}
interface ComponentView {
View onCreateComponent();
}
// Other getters and setters for variables
}
XML Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.twilio.video.VideoTextureView
android:id="@+id/video_view_top_right"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- Other components and buttons -->
</FrameLayout>
</LinearLayout>
Please note that I've omitted the XML error section since it doesn't contain specific code or content to translate. If you need assistance with that error, feel free to provide more information about the issue you're facing.
英文:
I want to play local video with VideoTextureView in Twilio library. Can you help me?
package com.bariskarapelit.touchcontrol;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.widget.VideoView;
import com.twilio.video.VideoTextureView;
public class MainActivity extends AppCompatActivity
{
ImageButton circleButton,likeButton,dislikeButton;
VideoView videoView;
String videoPath;
VideoTextureView videoTextureView;
Uri uri;
ImageView imageView ;
int selectedImage = R.drawable.circlepng;
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = new ImageView(this);
//Burası defult resim. Butonlara tıklamadğında ilk olarak varsayılan olarka koaycağınız resim olacak.
imageView.setImageResource(R.drawable.circlepng);
final FrameLayout frameLayout = findViewById(R.id.frame_layout);
LinearLayout linearLayout= findViewById(R.id.linearlayout);
circleButton=findViewById(R.id.circle);
dislikeButton=findViewById(R.id.dislike);
likeButton=findViewById(R.id.like);
videoTextureView=findViewById(R.id.video_view_top_right);
//Burdaki hangi viewi dinleyeceği hocam.
MultiTouchControl multiTouchControl = new MultiTouchControl(frameLayout, new MultiTouchControl.ComponentView() {
@Override
public View onCreateComponent() {
ImageView image = new ImageView(frameLayout.getContext());
image.setImageResource(selectedImage);
return image;
}
});
multiTouchControl.startListener();
setupButtons();
}
private void setupButtons(){
circleButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
Toast.makeText(MainActivity.this,"Circle",Toast.LENGTH_LONG).show();
selectedImage = R.drawable.circlepng;
}
});
dislikeButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
Toast.makeText(MainActivity.this,"Dislike",Toast.LENGTH_LONG).show();
selectedImage = R.drawable.dislike;
}
});
likeButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
Toast.makeText(MainActivity.this,"Like",Toast.LENGTH_LONG).show();
selectedImage = R.drawable.like;
}
});
}
}
MultiTouchControl Code:
package com.bariskarapelit.touchcontrol;
import android.annotation.SuppressLint;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
public class MultiTouchControl implements View.OnTouchListener {
private ViewGroup root;
private ComponentView componentView;
private float circleSize = 100;
private int duration = 1500;
private List<Vector3> fingerTips = new ArrayList<>();
private boolean enabled = true;
public MultiTouchControl(ViewGroup root, ComponentView componentView, float circleSize, int duration) {
this.root = root;
this.componentView = componentView;
this.circleSize = circleSize;
this.duration = duration;
}
public MultiTouchControl(ViewGroup root, ComponentView componentView) {
this.root = root;
this.componentView = componentView;
}
public void startListener(){
root.setOnTouchListener(this);
}
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
if (!enabled)
return false;
final int points = event.getPointerCount();
int removedPoint = -1;
final int action = event.getAction() & MotionEvent.ACTION_MASK;
if (event.getAction() == MotionEvent.ACTION_MOVE) {
fingerTips.clear();
return false;
}
if (action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_UP)
removedPoint = (action & MotionEvent.ACTION_POINTER_INDEX_MASK)
>> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
fingerTips.clear();
for (int i = 0; i < points; i++) {
int pointerID = event.getPointerId(i);
if (pointerID == MotionEvent.INVALID_POINTER_ID) {
continue;
}
if (removedPoint == i) {
continue;
}
fingerTips.add(new Vector3(event.getX(i), event.getY(i), pointerID));
}
for (Vector3 fingerTip : fingerTips) {
createCircle(fingerTip.x, fingerTip.y);
}
return true;
}
private void createCircle(float x, float y) {
if (componentView != null) {
View view = componentView.onCreateComponent();
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
view.setX(x - circleSize / 2);
view.setY(y - circleSize / 2);
params.width = (int) circleSize;
params.height = (int) circleSize;
view.setLayoutParams(params);
root.addView(view);
dieAfter(view);
}
}
private void dieAfter(final View view) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
root.removeView(view);
}
}, duration);
}
static class Vector3 {
public float x, y;
public int id;
public Vector3(float x, float y, int id) {
this.x = x;
this.y = y;
this.id = id;
}
}
interface ComponentView {
View onCreateComponent();
}
public ViewGroup getRoot() {
return root;
}
public MultiTouchControl setRoot(ViewGroup root) {
this.root = root;
return this;
}
public ComponentView getComponentView() {
return componentView;
}
public MultiTouchControl setComponentView(ComponentView componentView) {
this.componentView = componentView;
return this;
}
public float getCircleSize() {
return circleSize;
}
public MultiTouchControl setCircleSize(float circleSize) {
this.circleSize = circleSize;
return this;
}
public int getDuration() {
return duration;
}
public MultiTouchControl setDuration(int duration) {
this.duration = duration;
return this;
}
public MultiTouchControl setEnabled(boolean enabled) {
this.enabled = enabled;
return this;
}
}
Xml codes
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.twilio.video.VideoTextureView
android:id="@+id/video_view_top_right"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
android:gravity="center"
android:orientation="horizontal">
<ImageButton
android:id="@+id/circle"
android:layout_width="51dp"
android:layout_height="51dp"
android:layout_marginRight="50dp"
android:background="@mipmap/launch1" />
<ImageButton
android:id="@+id/dislike"
android:layout_width="51dp"
android:layout_height="51dp"
android:layout_marginRight="50dp"
android:background="@mipmap/launch2"></ImageButton>
<ImageButton
android:id="@+id/like"
android:layout_width="51dp"
android:layout_height="51dp"
android:background="@mipmap/launch3"
></ImageButton>
</LinearLayout>
</FrameLayout>
</LinearLayout>
I get this error when I add it to the Video Texture View xml file
Error Code:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.bariskarapelit.touchcontrol, PID: 6041
java.lang.BootstrapMethodError: Exception from call site #72 bootstrap method
at tvi.webrtc.EglRenderer.init(EglRenderer.java:181)
at com.twilio.video.VideoTextureView.init(VideoTextureView.java:223)
at com.twilio.video.VideoTextureView.init(VideoTextureView.java:208)
at com.twilio.video.VideoTextureView.onAttachedToWindow(VideoTextureView.java:109)
I want to play the local video with Video Texture View, but when I add Video Texture View to the xml file, it gives this error.
答案1
得分: 0
至少 Twilio 库支持 Android 8。
我的项目版本适用于 Android 8 或更低版本。
英文:
At least the Twilio library supports Android 8.
The version of my project is subordinate to Android 8
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论