Android: videoview in dialogfragment
Quiero mostrar VideoView
en DialogFragment
. Ahora, me enfrento a dos problemas:
- VideoView muestra un video más oscuro:
La razón es que VideoView se dibuja detrás de la ventana del diálogo. Apliqué,
- Android VideoView cómo escalar como tipo de escala ImageView fitXY?
- Stream URL RTSP utilizando VideoView en android
- Tableta Android con vídeo incorporado pierde video en rotación
- Android obtener captura de pantalla de videoview actual
- VideoView no reproduce vídeo en bucle solo en Galaxy s4
mVideoView.setZOrderOnTop(true);
Pero sin éxito, mostró color blanco en lugar de VideoView. Para esto, me referí a esta pregunta SO.
- Incluso los controladores de medios se esconden detrás de la ventana. No hay manera de que pueda tocar y llevar los controladores de medios de nuevo a visible. No encontré ninguna forma de hacer que se ejecute.
Cualquiera puede por favor hacer este trabajo o sugerir cualquier solución ..?
Código en 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>
- Orientación de vídeo de retrato de Android incorrecta en VideoView
- VideoView no sigue la configuración de orientación de la actividad
- Android: Reproductor de video como la aplicación de Dailymotion
- Cómo capturar / grabar un clip desde URL de vídeo en Android y guardarlo en el teléfono
- ¿Cómo uso realmente ffmpeg en Android?
- Cómo activar FullScreen con VideoView Android
- Cómo mostrar un video desde una URL
- Androids MediaPlayer reproduce video cada dos veces que la actividad entra
- Android FFmpegMediaPlayer Error (0, 0) mientras se reproduce?
- No se puede comprobar el botón de radio