Pausar y reanudar la reproducción

Cuando un usuario hace clic en una publicidad, la aplicación debe pausar la reproducción del contenido de vídeo principal.

  1. Anule onPause y onResume de la actividad de Android.

    @Override 
    public void onResume() { 
        super.onResume(); 
        requestAudioFocus(); 
        if (_lastKnownStatus == MediaPlayerStatus.PAUSED) { 
            _mediaPlayer.play(); 
        } 
    } 
    ... 
    
    @Override 
    public void onPause() { 
        super.onPause(); 
        if (_mediaPlayer != null) { 
            if (_mediaPlayer.getStatus() == MediaPlayerStatus.PLAYING || 
              _mediaPlayer.getStatus() == MediaPlayerStatus.PAUSED) { 
                _savedPlayerStatus = _mediaPlayer.getStatus(); 
                _lastKnownTime = _mediaPlayer.getCurrentTime(); 
            } 
            if (_mediaPlayer.getStatus() == MediaPlayerStatus.PLAYING) { 
                _mediaPlayer.pause(); 
                _lastKnownStatus = MediaPlayerStatus.PAUSED; 
            } 
        } 
    } 
    abandonAudioFocus(); 
    

En esta página

Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now