コード例 #1
0
  /**
   * Requests the DefaultControls to become visible. This should only be called after {@link
   * #setDefaultControlsEnabled(boolean)}.
   */
  public void showDefaultControls() {
    if (defaultControls != null) {
      defaultControls.show();

      if (isPlaying()) {
        defaultControls.hideDelayed(DefaultControls.DEFAULT_CONTROL_HIDE_DELAY);
      }
    }
  }
コード例 #2
0
  /**
   * If a video is currently in playback then the playback will be stopped and the progressPoll will
   * be stopped (see {@link #startProgressPoll()})
   */
  public void stopPlayback() {
    if (!useExo) {
      videoView.stopPlayback();
    } else {
      emExoPlayer.setPlayWhenReady(false);
    }

    if (defaultControls != null) {
      defaultControls.updatePlayPauseImage(false);
      defaultControls.show();
    }

    playRequested = false;
    stopProgressPoll();
  }
コード例 #3
0
  /**
   * Starts the playback for the video specified in {@link #setVideoURI(android.net.Uri)} or {@link
   * #setVideoPath(String)}. This should be called after the VideoView is correctly prepared (see
   * {@link #setOnPreparedListener(android.media.MediaPlayer.OnPreparedListener)})
   */
  public void start() {
    if (!useExo) {
      videoView.start();
    } else {
      emExoPlayer.setPlayWhenReady(true);
    }

    if (defaultControls != null) {
      defaultControls.updatePlayPauseImage(true);
      defaultControls.hideDelayed(DefaultControls.DEFAULT_CONTROL_HIDE_DELAY);
    }

    playRequested = true;
    startProgressPoll();
  }
コード例 #4
0
  /**
   * If a video is currently in playback then the playback will be suspended and and the
   * progressPoll will be stopped (see {@link #startProgressPoll()})
   */
  public void suspend() {
    if (!useExo) {
      videoView.suspend();
    } else {
      emExoPlayer.release();
    }

    if (defaultControls != null) {
      defaultControls.updatePlayPauseImage(false);
      defaultControls.show();
    }

    playRequested = false;
    stopProgressPoll();
  }
コード例 #5
0
  /**
   * Sets the bus to use for dispatching Events that correspond to the callbacks listed in {@link
   * com.devbrackets.android.exomedia.listener.EMVideoViewControlsCallback}
   *
   * @param bus The EventBus to dispatch events on
   */
  public void setBus(@Nullable EMEventBus bus) {
    this.bus = bus;
    listenerMux.setBus(bus);

    if (defaultControls != null) {
      defaultControls.setBus(bus);
    }
  }
コード例 #6
0
  /**
   * Enables and disables the media control overlay for the video view
   *
   * @param enabled Weather the default video controls are enabled (default: false)
   */
  public void setDefaultControlsEnabled(boolean enabled) {
    if (defaultControls == null && enabled) {
      defaultControls =
          EMDeviceUtil.isDeviceTV(getContext())
              ? new DefaultControlsLeanback(getContext())
              : new DefaultControlsMobile(getContext());
      defaultControls.setVideoView(this);
      defaultControls.setBus(bus);

      addView(defaultControls);
      startProgressPoll();
    } else if (defaultControls != null && !enabled) {
      removeView(defaultControls);
      defaultControls = null;

      if (bus == null) {
        stopProgressPoll();
      }
    }

    // Sets the onTouch listener to show the default controls
    TouchListener listener = new TouchListener(getContext());
    setOnTouchListener(enabled ? listener : null);
  }
コード例 #7
0
  /**
   * Sets the Uri location for the video to play
   *
   * @param uri The video's Uri
   * @param defaultMediaType The MediaType to use when auto-detection fails
   */
  public void setVideoURI(Uri uri, MediaUtil.MediaType defaultMediaType) {
    videoUri = uri;

    if (!useExo) {
      videoView.setVideoURI(uri);
    } else {
      if (uri == null) {
        emExoPlayer.replaceRenderBuilder(null);
      } else {
        emExoPlayer.replaceRenderBuilder(
            getRendererBuilder(VideoType.get(uri), uri, defaultMediaType));
        listenerMux.setNotifiedCompleted(false);
      }

      // Makes sure the listeners get the onPrepared callback
      listenerMux.setNotifiedPrepared(false);
      emExoPlayer.seekTo(0);
    }

    if (defaultControls != null) {
      defaultControls.restartLoading();
    }
  }
コード例 #8
0
 /**
  * Sets the state list drawable resource id to use for the Previous button. {@link
  * #setDefaultControlsEnabled(boolean)} must be called prior to this.
  *
  * @param resourceId The resourceId or 0
  */
 public void setPreviousImageResource(@DrawableRes int resourceId) {
   if (defaultControls != null) {
     defaultControls.setPreviousImageResource(resourceId);
   }
 }
コード例 #9
0
 /**
  * Sets the button state for the Previous button on the default controls; see {@link
  * #setDefaultControlsEnabled(boolean)}. {@link #setDefaultControlsEnabled(boolean)} must be
  * called prior to this.
  *
  * <p>This will just change the images specified with {@link #setPreviousImageResource(int)}, or
  * use the defaults if they haven't been set, and block any click events.
  *
  * <p>This method will NOT re-add buttons that have previously been removed with {@link
  * #setPreviousButtonRemoved(boolean)}.
  *
  * @param enabled If the Previous button is enabled [default: false]
  */
 public void setPreviousButtonEnabled(boolean enabled) {
   if (defaultControls != null) {
     defaultControls.setPreviousButtonEnabled(enabled);
   }
 }
コード例 #10
0
 /**
  * Sets the button state for the Rewind button on the default controls; see {@link
  * #setDefaultControlsEnabled(boolean)}. {@link #setDefaultControlsEnabled(boolean)} must be
  * called prior to this.
  *
  * <p>This will just change the images specified with {@link #setRewindImageResource(int)}, or use
  * the defaults if they haven't been set, and block any click events.
  *
  * <p>This method will NOT re-add buttons that have previously been removed with {@link
  * #setRewindButtonRemoved(boolean)}.
  *
  * @param enabled If the Rewind button is enabled [default: false]
  */
 public void setRewindButtonEnabled(boolean enabled) {
   if (defaultControls != null) {
     defaultControls.setRewindButtonEnabled(enabled);
   }
 }
コード例 #11
0
 /**
  * Adds or removes the Fast Forward button. This will change the visibility of the button, if you
  * want to change the enabled/disabled images see {@link #setFastForwardButtonEnabled(boolean)}
  * {@link #setDefaultControlsEnabled(boolean)} must be called prior to this.
  *
  * @param removed If the Fast Forward button should be removed [default: false]
  */
 public void setFastForwardButtonRemoved(boolean removed) {
   if (defaultControls != null) {
     defaultControls.setFastForwardButtonRemoved(removed);
   }
 }
コード例 #12
0
 /**
  * Adds or removes the Rewind button. This will change the visibility of the button, if you want
  * to change the enabled/disabled images see {@link #setRewindButtonEnabled(boolean)} {@link
  * #setDefaultControlsEnabled(boolean)} must be called prior to this.
  *
  * @param removed If the Rewind button should be removed [default: false]
  */
 public void setRewindButtonRemoved(boolean removed) {
   if (defaultControls != null) {
     defaultControls.setRewindButtonRemoved(removed);
   }
 }
コード例 #13
0
 /**
  * Adds or removes the Previous button. This will change the visibility of the button, if you want
  * to change the enabled/disabled images see {@link #setPreviousButtonEnabled(boolean)} {@link
  * #setDefaultControlsEnabled(boolean)} must be called prior to this.
  *
  * @param removed If the Previous button should be removed [default: true]
  */
 public void setPreviousButtonRemoved(boolean removed) {
   if (defaultControls != null) {
     defaultControls.setPreviousButtonRemoved(removed);
   }
 }
コード例 #14
0
 /**
  * Sets the state list drawable resource id to use for the Fast Forward button. {@link
  * #setDefaultControlsEnabled(boolean)} must be called prior to this.
  *
  * @param resourceId The resourceId or 0
  */
 public void setFastForwardImageResource(@DrawableRes int resourceId) {
   if (defaultControls != null) {
     defaultControls.setFastForwardImageResource(resourceId);
   }
 }
コード例 #15
0
 /**
  * Sets the resource id's to use for the PlayPause button. {@link
  * #setDefaultControlsEnabled(boolean)} must be called prior to this.
  *
  * @param playResourceId The resourceId or 0
  * @param pauseResourceId The resourceId or 0
  */
 public void setPlayPauseImages(
     @DrawableRes int playResourceId, @DrawableRes int pauseResourceId) {
   if (defaultControls != null) {
     defaultControls.setPlayPauseImages(playResourceId, pauseResourceId);
   }
 }
コード例 #16
0
 /**
  * Sets the EMVideoViewControlsCallback to be used. {@link #setDefaultControlsEnabled(boolean)}
  * must be called prior to this.
  *
  * @param callback The EMVideoViewControlsCallback to use
  */
 public void setVideoViewControlsCallback(EMVideoViewControlsCallback callback) {
   if (defaultControls != null) {
     defaultControls.setVideoViewControlsCallback(callback);
   }
 }
コード例 #17
0
 /**
  * Sets the button state for the Fast Forward button on the default controls; see {@link
  * #setDefaultControlsEnabled(boolean)}. {@link #setDefaultControlsEnabled(boolean)} must be
  * called prior to this.
  *
  * <p>This will just change the images specified with {@link #setFastForwardImageResource(int)},
  * or use the defaults if they haven't been set, and block any click events.
  *
  * <p>This method will NOT re-add buttons that have previously been removed with {@link
  * #setFastForwardButtonRemoved(boolean)}.
  *
  * @param enabled If the Fast Forward button is enabled [default: false]
  */
 public void setFastForwardButtonEnabled(boolean enabled) {
   if (defaultControls != null) {
     defaultControls.setFastForwardButtonEnabled(enabled);
   }
 }