private long getSkipDuration() {
    if (hasSkipDuration()) {
      UnityAdsZone currentZone = UnityAdsWebData.getZoneManager().getCurrentZone();
      return currentZone.allowVideoSkipInSeconds();
    }

    return 0;
  }
  public int getSecondsUntilBackButtonAllowed() {
    int timeUntilBackButton = 0;

    UnityAdsZone currentZone = UnityAdsWebData.getZoneManager().getCurrentZone();
    if (currentZone.disableBackButtonForSeconds() > 0 && _videoStartedPlayingMillis > 0) {
      timeUntilBackButton =
          Math.round(
              (currentZone.disableBackButtonForSeconds() * 1000)
                  - (System.currentTimeMillis() - _videoStartedPlayingMillis));
      if (timeUntilBackButton < 0) timeUntilBackButton = 0;
    } else if (currentZone.allowVideoSkipInSeconds() > 0 && _videoStartedPlayingMillis <= 0) {
      return 1;
    }

    return timeUntilBackButton;
  }
 private boolean hasSkipDuration() {
   UnityAdsZone currentZone = UnityAdsWebData.getZoneManager().getCurrentZone();
   return currentZone.allowVideoSkipInSeconds() > 0;
 }
  private void createView() {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    _layout = (RelativeLayout) inflater.inflate(R.layout.unityads_view_video_play, this);

    UnityAdsZone currentZone = UnityAdsWebData.getZoneManager().getCurrentZone();
    if (currentZone.muteVideoSounds()) {
      _muted = true;
    }

    _videoView = (UnityAdsVideoView) _layout.findViewById(R.id.unityAdsVideoView);
    _videoView.setClickable(true);
    _videoView.setOnCompletionListener(
        new MediaPlayer.OnCompletionListener() {
          @Override
          public void onCompletion(MediaPlayer mp) {
            _listener.onCompletion(mp);
          }
        });
    _videoView.setOnPreparedListener(
        new MediaPlayer.OnPreparedListener() {
          @Override
          public void onPrepared(MediaPlayer mp) {
            UnityAdsDeviceLog.entered();
            _mediaPlayer = mp;

            if (_muted) {
              storeVolume();
              _mediaPlayer.setVolume(0f, 0f);
            }

            _videoPlayheadPrepared = true;
          }
        });

    _bufferingText = (TextView) _layout.findViewById(R.id.unityAdsVideoBufferingText);
    _countDownText = (LinearLayout) _layout.findViewById(R.id.unityAdsVideoCountDown);
    _timeLeftInSecondsText = (TextView) _layout.findViewById(R.id.unityAdsVideoTimeLeftText);
    _timeLeftInSecondsText.setText(R.string.unityads_default_video_length_text);
    _skipTextView = (TextView) _layout.findViewById(R.id.unityAdsVideoSkipText);
    _muteButton = new UnityAdsMuteVideoButton(getContext());
    _muteButton.setLayout((RelativeLayout) _layout.findViewById(R.id.unityAdsAudioToggleView));

    if (_muted) {
      _muteButton.setState(UnityAdsMuteVideoButton.UnityAdsMuteVideoButtonState.Muted);
    }

    _layout
        .findViewById(R.id.unityAdsAudioToggleView)
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                if (_videoPlayheadPrepared && _videoPlaybackStartedSent) {
                  if (_muted) {
                    _muted = false;
                    _muteButton.setState(
                        UnityAdsMuteVideoButton.UnityAdsMuteVideoButtonState.UnMuted);
                    _mediaPlayer.setVolume(_volumeBeforeMute, _volumeBeforeMute);
                  } else {
                    _muted = true;
                    _muteButton.setState(
                        UnityAdsMuteVideoButton.UnityAdsMuteVideoButtonState.Muted);
                    storeVolume();
                    _mediaPlayer.setVolume(0f, 0f);
                  }
                }
              }
            });

    if (UnityAdsProperties.UNITY_DEVELOPER_INTERNAL_TEST) {
      RelativeLayout stagingLayout = new RelativeLayout(getContext());
      RelativeLayout.LayoutParams stagingParams =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      stagingParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      stagingParams.addRule(RelativeLayout.CENTER_VERTICAL);
      stagingLayout.setLayoutParams(stagingParams);

      TextView stagingText = new TextView(getContext());
      stagingText.setTextColor(Color.RED);
      stagingText.setBackgroundColor(Color.BLACK);
      stagingText.setText("INTERNAL UNITY TEST BUILD\nDO NOT USE IN PRODUCTION");

      stagingLayout.addView(stagingText);
      addView(stagingLayout);
    }

    if (hasSkipDuration()) {
      updateSkipText(getSkipDuration());
    }

    setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (!_videoView.isPlaying()) {
              hideVideoPausedView();
              startVideo();
            }
          }
        });
  }