Android YouTubePlayer con superposición no autorizada encima del reproductor
Estoy usando YouTubePlayer (api de YouTube para android) dentro de un fragmento Estoy inflando un LinearLayout con el reproductor de YouTube, de esta manera:
fragmentManager = getActivity().getSupportFragmentManager(); fragmentTransaction = fragmentManager.beginTransaction(); player = new YouTubePlayerSupportFragment(); fragmentTransaction.add(R.id.youTubePlayerContainer, player); fragmentTransaction.commit();
… Donde youTubePlayerContainer es el LinearLayout inflado
- Reproducir video de Youtube en segundo plano usando el reproductor de youtube api
- YouTubePlayerSupportFragment en el elemento ListView es nulo
- Vídeos múltiples de YouTube para Android en la actividad
- YouTubeAndroidPlayer en Android se bloquea en play ()
- Límites de cuota para la API del reproductor de YouTube para Android
El reproductor se detecta correctamente, empieza a jugar y en un segundo se detiene. El registro muestra lo siguiente:
YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.widget.FrameLayout@4110d1f8. YouTubePlayerView is completely covered, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 484, top: 100, right: 100, bottom: 170..
Este es mi XML: (No FrameLayout dentro de él)
<LinearLayout android:id="@+id/curtain" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/withApi" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <LinearLayout android:id="@+id/youTubePlayerContainer" android:layout_width="match_parent" android:layout_height="0dp" android:layout_gravity="center" android:layout_margin="30dp" android:layout_weight="1" android:orientation="vertical" > </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="3dp" android:background="@color/trans_popUp" android:padding="3dp" > <TextView android:id="@+id/textYouTubeVisor" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Title..." android:textColor="@color/white" /> </LinearLayout> </LinearLayout>
Traté de cambiar los márgenes sin éxito. He leído la documentación oficial pero sin éxito Indica que el FrameLayout que causa el problema es: android.widget.FrameLayout @ 4110d1f8 Pero con tal referencia no se identifica que se refiere
A alguien que hizo esto?
Aprecio cualquier ayuda.
Saludos
- API de datos de Youtube con OAuth2.0 en Android
- Los anuncios de YouTube no se muestran al usar la API de reproductor de YouTube para Android
- ¿Cómo puedo ocultar controles, botones de pantalla completa en Youtube Player android API?
- Android: intentando obtener datos de youtube api
- Varios jugadores de Youtube en una actividad
- Pausa de la API de YouTube de YouTube cuando gira la pantalla u oculta el reproductor
- Actividad de la API de YoutubeNotFoundException en Gingerbread
- No se pudo encontrar un error de clase al intentar cargar un video a YouTube usando la API de gdata.
¿Fue capaz de resolver este problema?
Me enfrenté al mismo problema hoy, y para mí el error en los registros fue:
W/YouTubeAndroidPlayerAPI﹕ YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor com.google.android.youtube.player.YouTubePlayerView{42686bc8 VE.... ........ 0,0-1200,675 #7f0a00a0 app:id/video_player}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: -10, top: -10, right: -10, bottom: -10 (these should all be positive).
Fijé esto quitando el acolchado en YouTubePlayerView en la disposición. Así que mi diseño se ve así:
<com.google.android.youtube.player.YouTubePlayerView android:id="@+id/video_player" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#000" />
El problema es solo el diseño, el reproductor de youtube no permite que nadie se quede sobre esto, lo mismo invisible o transparente.
En camino a descubrir esto es con la opción de desarrollador mostrar los límites de diseño. (Advertencia con rellenos y márgenes)
Intentar comentar otras vistas en su diseño y probar de nuevo por favor.
Youtube Player descubre algunas vistas que lo superponen. Sólo tienes que quitar las vistas o setVisible (View.GONE) para ellos. Por favor, consulte este enlace para obtener más información Solución
El código de demostración de la API de Android utiliza este diseño para la demostración Fragment, tal vez eso puede hacer que las ideas vayan. Consulta esta página: https://developers.google.com/youtube/android/player/
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:textAppearance="@android:style/TextAppearance.Small" android:gravity="center" android:text="@string/playerfragment_text"/> <fragment android:name="com.google.android.youtube.player.YouTubePlayerFragment" android:id="@+id/youtube_fragment" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
Debe eliminar cualquier atributo de relleno en la vista de vídeo.
Incorrecto:
<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="match_parent" android:orientation="vertical" > <com.google.android.youtube.player.YouTubePlayerView android:id="@+id/youtube_player" android:layout_width="match_parent" android:layout_height="match_parent" **android:padding="10dp"** /> </LinearLayout>
Derecha:
<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="match_parent" android:orientation="vertical" > <com.google.android.youtube.player.YouTubePlayerView android:id="@+id/youtube_player" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
- Android: ¿Cómo puedo comprobar un elemento en particular en CheckView ListView?
- ¿Se puede obligar a bindService () a bloquear?