Search in sources :

Example 1 with RequirementsWatcher

use of com.google.android.exoplayer2.scheduler.RequirementsWatcher in project ExoPlayer by google.

the class DownloadManager method setRequirements.

/**
 * Sets the requirements that need to be met for downloads to progress.
 *
 * @param requirements A {@link Requirements}.
 */
public void setRequirements(Requirements requirements) {
    if (requirements.equals(requirementsWatcher.getRequirements())) {
        return;
    }
    requirementsWatcher.stop();
    requirementsWatcher = new RequirementsWatcher(context, requirementsListener, requirements);
    int notMetRequirements = requirementsWatcher.start();
    onRequirementsStateChanged(requirementsWatcher, notMetRequirements);
}
Also used : RequirementsWatcher(com.google.android.exoplayer2.scheduler.RequirementsWatcher)

Example 2 with RequirementsWatcher

use of com.google.android.exoplayer2.scheduler.RequirementsWatcher in project ExoPlayer by google.

the class DownloadManager method onRequirementsStateChanged.

private void onRequirementsStateChanged(RequirementsWatcher requirementsWatcher, @Requirements.RequirementFlags int notMetRequirements) {
    Requirements requirements = requirementsWatcher.getRequirements();
    if (this.notMetRequirements != notMetRequirements) {
        this.notMetRequirements = notMetRequirements;
        pendingMessages++;
        internalHandler.obtainMessage(MSG_SET_NOT_MET_REQUIREMENTS, notMetRequirements, /* unused */
        0).sendToTarget();
    }
    boolean waitingForRequirementsChanged = updateWaitingForRequirements();
    for (Listener listener : listeners) {
        listener.onRequirementsStateChanged(this, requirements, notMetRequirements);
    }
    if (waitingForRequirementsChanged) {
        notifyWaitingForRequirementsChanged();
    }
}
Also used : Requirements(com.google.android.exoplayer2.scheduler.Requirements)

Aggregations

Requirements (com.google.android.exoplayer2.scheduler.Requirements)1 RequirementsWatcher (com.google.android.exoplayer2.scheduler.RequirementsWatcher)1