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)

huangapple go评论65阅读模式
英文:

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(&quot;ClickableViewAccessibility&quot;)
@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,&quot;Circle&quot;,Toast.LENGTH_LONG).show();
selectedImage = R.drawable.circlepng;
}
});
dislikeButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
Toast.makeText(MainActivity.this,&quot;Dislike&quot;,Toast.LENGTH_LONG).show();
selectedImage = R.drawable.dislike;
}
});
likeButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
Toast.makeText(MainActivity.this,&quot;Like&quot;,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&lt;Vector3&gt; fingerTips = new ArrayList&lt;&gt;();
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(&quot;ClickableViewAccessibility&quot;)
@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() &amp; 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 &amp; MotionEvent.ACTION_POINTER_INDEX_MASK)
&gt;&gt; MotionEvent.ACTION_POINTER_INDEX_SHIFT;
fingerTips.clear();
for (int i = 0; i &lt; 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

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
android:id=&quot;@+id/linearlayout&quot;
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;match_parent&quot;&gt;
&lt;FrameLayout
android:id=&quot;@+id/frame_layout&quot;
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;match_parent&quot;&gt;
&lt;com.twilio.video.VideoTextureView
android:id=&quot;@+id/video_view_top_right&quot;
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;match_parent&quot;
/&gt;
&lt;LinearLayout
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:layout_gravity=&quot;bottom&quot;
android:layout_marginBottom=&quot;10dp&quot;
android:gravity=&quot;center&quot;
android:orientation=&quot;horizontal&quot;&gt;
&lt;ImageButton
android:id=&quot;@+id/circle&quot;
android:layout_width=&quot;51dp&quot;
android:layout_height=&quot;51dp&quot;
android:layout_marginRight=&quot;50dp&quot;
android:background=&quot;@mipmap/launch1&quot; /&gt;
&lt;ImageButton
android:id=&quot;@+id/dislike&quot;
android:layout_width=&quot;51dp&quot;
android:layout_height=&quot;51dp&quot;
android:layout_marginRight=&quot;50dp&quot;
android:background=&quot;@mipmap/launch2&quot;&gt;&lt;/ImageButton&gt;
&lt;ImageButton
android:id=&quot;@+id/like&quot;
android:layout_width=&quot;51dp&quot;
android:layout_height=&quot;51dp&quot;
android:background=&quot;@mipmap/launch3&quot;
&gt;&lt;/ImageButton&gt;
&lt;/LinearLayout&gt;
&lt;/FrameLayout&gt;
&lt;/LinearLayout&gt;

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

huangapple
  • 本文由 发表于 2020年8月28日 05:25:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63624372.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定