use of androidx.annotation.Nullable in project ExoPlayer by google.
the class ConcatenatingMediaSource method setPublicShuffleOrder.
@GuardedBy("this")
private void setPublicShuffleOrder(ShuffleOrder shuffleOrder, @Nullable Handler handler, @Nullable Runnable onCompletionAction) {
Assertions.checkArgument((handler == null) == (onCompletionAction == null));
@Nullable Handler playbackThreadHandler = this.playbackThreadHandler;
if (playbackThreadHandler != null) {
int size = getSize();
if (shuffleOrder.getLength() != size) {
shuffleOrder = shuffleOrder.cloneAndClear().cloneAndInsert(/* insertionIndex= */
0, /* insertionCount= */
size);
}
@Nullable HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
playbackThreadHandler.obtainMessage(MSG_SET_SHUFFLE_ORDER, new MessageData<>(/* index= */
0, shuffleOrder, callbackAction)).sendToTarget();
} else {
this.shuffleOrder = shuffleOrder.getLength() > 0 ? shuffleOrder.cloneAndClear() : shuffleOrder;
if (onCompletionAction != null && handler != null) {
handler.post(onCompletionAction);
}
}
}
use of androidx.annotation.Nullable in project ExoPlayer by google.
the class ConcatenatingMediaSource method createPeriod.
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
Object mediaSourceHolderUid = getMediaSourceHolderUid(id.periodUid);
MediaPeriodId childMediaPeriodId = id.copyWithPeriodUid(getChildPeriodUid(id.periodUid));
@Nullable MediaSourceHolder holder = mediaSourceByUid.get(mediaSourceHolderUid);
if (holder == null) {
// Stale event. The media source has already been removed.
holder = new MediaSourceHolder(new FakeMediaSource(), useLazyPreparation);
holder.isRemoved = true;
prepareChildSource(holder, holder.mediaSource);
}
enableMediaSource(holder);
holder.activeMediaPeriodIds.add(childMediaPeriodId);
MediaPeriod mediaPeriod = holder.mediaSource.createPeriod(childMediaPeriodId, allocator, startPositionUs);
mediaSourceByMediaPeriod.put(mediaPeriod, holder);
disableUnusedMediaSources();
return mediaPeriod;
}
use of androidx.annotation.Nullable in project ExoPlayer by google.
the class DefaultMediaSourceFactory method maybeWrapWithAdsMediaSource.
private MediaSource maybeWrapWithAdsMediaSource(MediaItem mediaItem, MediaSource mediaSource) {
checkNotNull(mediaItem.localConfiguration);
@Nullable MediaItem.AdsConfiguration adsConfiguration = mediaItem.localConfiguration.adsConfiguration;
if (adsConfiguration == null) {
return mediaSource;
}
@Nullable AdsLoader.Provider adsLoaderProvider = this.adsLoaderProvider;
@Nullable AdViewProvider adViewProvider = this.adViewProvider;
if (adsLoaderProvider == null || adViewProvider == null) {
Log.w(TAG, "Playing media without ads. Configure ad support by calling setAdsLoaderProvider and" + " setAdViewProvider.");
return mediaSource;
}
@Nullable AdsLoader adsLoader = adsLoaderProvider.getAdsLoader(adsConfiguration);
if (adsLoader == null) {
Log.w(TAG, "Playing media without ads, as no AdsLoader was provided.");
return mediaSource;
}
return new AdsMediaSource(mediaSource, new DataSpec(adsConfiguration.adTagUri), /* adsId= */
adsConfiguration.adsId != null ? adsConfiguration.adsId : ImmutableList.of(mediaItem.mediaId, mediaItem.localConfiguration.uri, adsConfiguration.adTagUri), /* adMediaSourceFactory= */
this, adsLoader, adViewProvider);
}
use of androidx.annotation.Nullable in project ExoPlayer by google.
the class Requirements method getNotMetNetworkRequirements.
@RequirementFlags
private int getNotMetNetworkRequirements(Context context) {
if (!isNetworkRequired()) {
return 0;
}
ConnectivityManager connectivityManager = (ConnectivityManager) Assertions.checkNotNull(context.getSystemService(Context.CONNECTIVITY_SERVICE));
@Nullable NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo == null || !networkInfo.isConnected() || !isInternetConnectivityValidated(connectivityManager)) {
return requirements & (NETWORK | NETWORK_UNMETERED);
}
if (isUnmeteredNetworkRequired() && connectivityManager.isActiveNetworkMetered()) {
return NETWORK_UNMETERED;
}
return 0;
}
use of androidx.annotation.Nullable in project ExoPlayer by google.
the class Requirements method isDeviceCharging.
private boolean isDeviceCharging(Context context) {
@Nullable Intent batteryStatus = context.registerReceiver(/* receiver= */
null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
if (batteryStatus == null) {
return false;
}
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;
}
Aggregations