Search in sources :

Example 1 with RequirementsWatcher

use of androidx.media3.exoplayer.scheduler.RequirementsWatcher in project media by androidx.

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(androidx.media3.exoplayer.scheduler.RequirementsWatcher)

Example 2 with RequirementsWatcher

use of androidx.media3.exoplayer.scheduler.RequirementsWatcher in project media by androidx.

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(androidx.media3.exoplayer.scheduler.Requirements)

Aggregations

Requirements (androidx.media3.exoplayer.scheduler.Requirements)1 RequirementsWatcher (androidx.media3.exoplayer.scheduler.RequirementsWatcher)1