android: видеоизглед в диалоговия фрагмент

Искам да покажа VideoView в DialogFragment. Сега се сблъсквам с два проблема:

  • VideoView показва по-тъмно видео:

Причината е, че VideoView е изчертан зад прозореца на диалоговия прозорец. кандидатствах,

mVideoView.setZOrderOnTop(true);

Но без успех, той показва бял цвят на мястото на VideoView. За това препоръчах това SO въпрос.

  • Дори медийните контролери се крият зад прозореца. Няма начин да докосна и да върна медийните контролери обратно към видими. Не намерих никакъв начин да направя това изпълнение.

Моля, някой може да направи това да работи или да предложи заобиколно решение..?

Код в onViewCreated():

        mMediaController = new MediaController(getActivity());
        mMediaController.setAnchorView(mVideoView);
        Uri video = Uri.parse(videoDetailByIdResponse.getData().getVideoFile());
        mVideoView.setMediaController(mMediaController);
        mVideoView.setVideoURI(video);
        mVideoView.requestFocus();
        //mVideoView.setZOrderOnTop(true);
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mMediaController.show();
                mVideoView.start();
            }
        });
        mVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
            @Override
            public boolean onError(MediaPlayer mp, int what, int extra) {
                return false;
            }
        });
        mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
            }
        });

layout_dialog_fragment.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:orientation="vertical">

    <VideoView
        android:id="@+id/vv_video_preview"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/colorPrimary"
        android:layout_weight="1"
        android:layout_gravity="center_horizontal" />

    <com.idolbee.android.customview.CustomTextView
        android:id="@+id/tv_user_profile_dialog_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:maxLines="2"
        android:padding="@dimen/padding_16"
        tools:text="My live performance at Sydney" />

    <!--Footer-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="@dimen/padding_16">

        <com.idolbee.android.customview.CustomTextView
            android:id="@+id/tv_user_profile_dialog_stings_and_comments"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/ic_sting_comment"
            android:drawablePadding="@dimen/padding_8"
            android:gravity="center"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            tools:text="@string/_1020_stings_210_comments" />

        <Space
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />

        <ImageView
            android:id="@+id/tv_user_profile_dialog_spam"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginRight="@dimen/margin_4"
            android:src="@drawable/ic_report" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorAccent">

        <com.idolbee.android.customview.CustomTextView
            android:id="@+id/tv_user_profile_dialog_sting"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawablePadding="@dimen/padding_8"
            android:drawableTop="@drawable/ic_sting_off"
            android:gravity="center"
            android:padding="@dimen/padding_8"
            android:text="@string/list_item_home_sting" />

        <com.idolbee.android.customview.CustomTextView
            android:id="@+id/tv_user_profile_dialog_comment"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawablePadding="@dimen/padding_8"
            android:drawableTop="@drawable/ic_comments"
            android:gravity="center"
            android:padding="@dimen/padding_8"
            android:text="@string/list_item_home_comment" />

        <com.idolbee.android.customview.CustomTextView
            android:id="@+id/tv_user_profile_dialog_share"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawablePadding="@dimen/padding_8"
            android:drawableTop="@drawable/ic_share"
            android:gravity="center"
            android:padding="@dimen/padding_8"
            android:text="@string/list_item_home_share" />

        <com.idolbee.android.customview.CustomTextView
            android:id="@+id/tv_user_profile_dialog_chat"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawablePadding="@dimen/padding_8"
            android:drawableTop="@drawable/ic_chat"
            android:gravity="center"
            android:padding="@dimen/padding_8"
            android:text="@string/list_item_home_chat" />

    </LinearLayout>

</LinearLayout>

person Chintan Soni    schedule 24.05.2016    source източник
comment
Намерихте ли отговор за това? Аз също имам същия проблем.   -  person Uma Achanta    schedule 16.12.2016
comment
@UmaAchanta Не. Няма решение на този проблем. Това е основен бъг в Android Framework. Единствената алтернатива на това е да използвате Fragment и да показвате като диалог със затъмнен фон.   -  person Chintan Soni    schedule 16.12.2016