为什么我的媒体控制器没有出现在VideoView的顶部?

时间:2018-11-19 04:59:45

标签: android

我知道这个问题已经被问过很多次了,但是我已经尝试了他们所有的建议,而没有任何解决方案。我究竟做错了什么?

我真的迷失了自己,我在用这个video.xml夸大AlertDialog,如果有人可以帮助这个迷失的灵魂,将不胜感激。

     LayoutInflater layoutInflater =    LayoutInflater.from(ResidentCareActivity.this);
    final View promptView = layoutInflater.inflate(R.layout.video, null);

        vv = promptView.findViewById(R.id.videoView); (vv already declared)

        final String url ="http://153.xxxx.xx.xx/Activites/20_24.mp4";

                    RequestQueue queue = Volley.newRequestQueue(someactivity.this);

                    // Request a string response from the provided URL.
                    StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
                            new Response.Listener<String>() {
                                @Override
                                public void onResponse(String response) {
                                    // Display the first 500 characters of the response string.
                                    vv.setVideoPath(url);
                                }
                            }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            L.e("pressToDo","Not a valid URL");
                            Toast.makeText(someactivity.this, "Not a valid URL", Toast.LENGTH_LONG).show();

                        }
                    });

                    // Add the request to the RequestQueue.
                    queue.add(stringRequest);
                    mediaController = new MediaController(someactivity.this);
                    vv.setMediaController(mediaController);
                    mediaController.setAnchorView(vv);
                    vv.start();

我的XML是

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <VideoView
        android:id="@+id/videoView"
        android:layout_width="381dp"
        android:layout_height="249dp"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginStart="0dp"
        android:layout_marginTop="0dp"
        app:srcCompat="@android:color/black" />

</RelativeLayout>

0 个答案:

没有答案