Personalizar las opciones del reproductor de vídeo en Android

ANVideoPlayerSettings permite que tu aplicación personalice los controles de la interfaz de usuario del reproductor de vídeo. Esta configuración se aplica a todos los anuncios de vídeo que ofrece el SDK de Android: vídeo instream, vídeo de banner (outstream) y vídeo intersticial.

La página Configuración de colocación de monetización (IU y API) expone opciones similares, pero solo algunas tienen efecto:

  • Opciones de la interfaz de usuario del reproductor de vídeo : ignoradas. El SDK usa solo los valores del lado cliente siguientes.
  • Configuración que no es de interfaz de usuario (versión VAST, tipos MIME, duraciones permitidas, etc.): aplicada. Estos determinan qué anuncios puede publicar Monetize.
Función Configuración predeterminada Descripción Bloques de anuncios que admiten la configuración
void shouldShowClickThroughControl(boolean showClickThroughControl) true Determina si se muestra el control click-through. Ponerlo en false hace que se pueda hacer clic en todo el vídeo. Instream / Vídeo de banner / Intersticial
void setClickThroughText(String clickThroughText) "Más información" Personaliza el texto asociado al control click-through. Instream / Vídeo de banner / Intersticial
void shouldShowFullScreenControl(boolean showFullScreenControl) true Controla la visibilidad del botón de pantalla completa. Vídeo de banner
void shouldShowTopBar(boolean showTopBar) true Obsoleto. Determina si se muestra la barra superior (que contiene los controles de clic y de omisión). Este método ya no es funcional y se quitará en una versión futura del SDK. Instream / Vídeo de banner
void shouldShowAdText(boolean showAdText) true Controla la visibilidad del texto del anuncio junto al control de clic. Instream / Vídeo de banner / Intersticial
void setAdText(String adText) "Anuncio" Personaliza el texto del anuncio en el reproductor de vídeo. Instream / Vídeo de banner / Intersticial
void shouldShowVolumeControl(boolean showVolumeControl) true Controla la visibilidad del control de silenciar o reactivar el audio. Instream / Vídeo de banner / Intersticial
void setInitialAudio(ANInitialAudioSetting initialAudio) Sonido activado (intersticial / instream), Sonido desactivado (vídeo de banner) Establece el estado de audio inicial. Instream / Vídeo de banner / Intersticial
void shouldShowSkip(boolean showSkip) true Controla la visibilidad del control Omitir. Instream / Intersticial
void setSkipDescription (cadenaskipDescription) "Omitir anuncio en %%TIME%%" Personaliza la descripción de la omisión. Instream / Intersticial
void setSkipLabelName (cadenaskipLabelName) "Omitir anuncio" Personaliza la etiqueta de omisión. Instream / Intersticial
void setSkipOffset (EnteroskipOffset) "5 segundos" Personaliza la omisión de desplazamiento. Instream / Intersticial
void shouldForceControlBarVisible (booleanoforceControlBarVisible) true Cuando se establece en true, la barra de control de vídeo (reproducir/pausa, buscar, volumen y otros controles) permanece permanentemente visible, independientemente de la interacción del usuario.
Cuando se establece en false, el jugador utiliza el comportamiento de ocultación automática, donde la barra de control se oculta después de un período de inactividad.
Instream / Vídeo de banner / Intersticial
void shouldClickBehaviorPausePlay(boolean clickBehaviorPausePlay) true Cuando se establece en true (predeterminado), al pulsar el vídeo se alterna reproducir/pausar. Cuando se establece en false, las pulsaciones se pasan a otros controladores (por ejemplo, click-through). Instream / Vídeo de banner / Intersticial

Ejemplo

// Show or hide the ClickThrough control on the video player. Default is true; setting it to false makes the entire video clickable
ANVideoPlayerSettings.getVideoPlayerSettings().shouldShowClickThroughControl(false);
 
// Change the ClickThrough text on the video player
ANVideoPlayerSettings.getVideoPlayerSettings().setClickThroughText("SampleText");
 
// Show or hide fullscreen control on the player. This is applicable only for Banner Video
ANVideoPlayerSettings.getVideoPlayerSettings().shouldShowFullScreenControl(true);
 
// Deprecated: this method is no longer functional and will be removed in a future SDK version
ANVideoPlayerSettings.getVideoPlayerSettings().shouldShowTopBar(true);
 
// Show or hide the "Ad" text next to the ClickThrough control
ANVideoPlayerSettings.getVideoPlayerSettings().shouldShowAdText(true);
ANVideoPlayerSettings.getVideoPlayerSettings().setAdText("Video Ad");
 
// Show or hide the volume control on the player
ANVideoPlayerSettings.getVideoPlayerSettings().shouldShowVolumeControl(true);
 
// Decide how the ad video sound starts initially (sound on or off). By default, Instream Video will have sound enabled, while Banner Video will have sound disabled
ANVideoPlayerSettings.getVideoPlayerSettings().setInitialAudio(ANInitialAudioSetting.DEFAULT);
ANVideoPlayerSettings.getVideoPlayerSettings().setInitialAudio(ANInitialAudioSetting.SOUND_ON);
ANVideoPlayerSettings.getVideoPlayerSettings().setInitialAudio(ANInitialAudioSetting.SOUND_OFF);
 
// Show or hide the Skip control on the player
ANVideoPlayerSettings.getVideoPlayerSettings().shouldShowSkip(true);
 
// Change the skip description on the video player
ANVideoPlayerSettings.getVideoPlayerSettings().setSkipDescription("Video Skip Demo");
 
// Change the skip button text on the video player
ANVideoPlayerSettings.getVideoPlayerSettings().setSkipLabelName("Test");
 
// Configure the skip offset on the video player. Minimum value is 5 seconds; lower values are clamped to 5
ANVideoPlayerSettings.getVideoPlayerSettings().setSkipOffset(2);

// Show or hide the control bar permanently (default is true to always show). If set to false, the player will auto-hide the control bar after inactivity.
ANVideoPlayerSettings.getVideoPlayerSettings().shouldForceControlBarVisible(false);

// When set to true (default), tapping the video toggles play/pause. Set to false to pass taps to other handlers (for example, click-through)
ANVideoPlayerSettings.getVideoPlayerSettings().shouldClickBehaviorPausePlay(false);