Search in sources :

Example 6 with Requirements

use of com.google.android.exoplayer2.scheduler.Requirements 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 7 with Requirements

use of com.google.android.exoplayer2.scheduler.Requirements 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)5 TestDownloadManagerListener (com.google.android.exoplayer2.robolectric.TestDownloadManagerListener)2 Nullable (androidx.annotation.Nullable)1 Constraints (androidx.work.Constraints)1 DefaultDownloaderFactory (com.google.android.exoplayer2.offline.DefaultDownloaderFactory)1 Download (com.google.android.exoplayer2.offline.Download)1 DownloadManager (com.google.android.exoplayer2.offline.DownloadManager)1 RequirementsWatcher (com.google.android.exoplayer2.scheduler.RequirementsWatcher)1 TestRunnable (com.google.android.exoplayer2.testutil.DummyMainThread.TestRunnable)1 FakeDataSource (com.google.android.exoplayer2.testutil.FakeDataSource)1 Factory (com.google.android.exoplayer2.upstream.DataSource.Factory)1 CacheDataSource (com.google.android.exoplayer2.upstream.cache.CacheDataSource)1 IOException (java.io.IOException)1