Java Code Examples for com.google.android.exoplayer2.util.Util#getLooper()

The following examples show how to use com.google.android.exoplayer2.util.Util#getLooper() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadHelper.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Creates download helper.
 *
 * @param downloadType A download type. This value will be used as {@link DownloadRequest#type}.
 * @param uri A {@link Uri}.
 * @param cacheKey An optional cache key.
 * @param mediaSource A {@link MediaSource} for which tracks are selected, or null if no track
 *     selection needs to be made.
 * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for
 *     downloading.
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers for which tracks
 *     are selected.
 */
public DownloadHelper(
    String downloadType,
    Uri uri,
    @Nullable String cacheKey,
    @Nullable MediaSource mediaSource,
    DefaultTrackSelector.Parameters trackSelectorParameters,
    RendererCapabilities[] rendererCapabilities) {
  this.downloadType = downloadType;
  this.uri = uri;
  this.cacheKey = cacheKey;
  this.mediaSource = mediaSource;
  this.trackSelector =
      new DefaultTrackSelector(trackSelectorParameters, new DownloadTrackSelection.Factory());
  this.rendererCapabilities = rendererCapabilities;
  this.scratchSet = new SparseIntArray();
  trackSelector.init(/* listener= */ () -> {}, new DummyBandwidthMeter());
  callbackHandler = new Handler(Util.getLooper());
  window = new Timeline.Window();
}
 
Example 2
Source File: DownloadHelper.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates download helper.
 *
 * @param downloadType A download type. This value will be used as {@link DownloadRequest#type}.
 * @param uri A {@link Uri}.
 * @param cacheKey An optional cache key.
 * @param mediaSource A {@link MediaSource} for which tracks are selected, or null if no track
 *     selection needs to be made.
 * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for
 *     downloading.
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers for which tracks
 *     are selected.
 */
public DownloadHelper(
    String downloadType,
    Uri uri,
    @Nullable String cacheKey,
    @Nullable MediaSource mediaSource,
    DefaultTrackSelector.Parameters trackSelectorParameters,
    RendererCapabilities[] rendererCapabilities) {
  this.downloadType = downloadType;
  this.uri = uri;
  this.cacheKey = cacheKey;
  this.mediaSource = mediaSource;
  this.trackSelector = new DefaultTrackSelector(new DownloadTrackSelection.Factory());
  this.rendererCapabilities = rendererCapabilities;
  this.scratchSet = new SparseIntArray();
  trackSelector.setParameters(trackSelectorParameters);
  trackSelector.init(/* listener= */ () -> {}, new DummyBandwidthMeter());
  callbackHandler = new Handler(Util.getLooper());
}
 
Example 3
Source File: DownloadHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates download helper.
 *
 * @param downloadType A download type. This value will be used as {@link DownloadRequest#type}.
 * @param uri A {@link Uri}.
 * @param cacheKey An optional cache key.
 * @param mediaSource A {@link MediaSource} for which tracks are selected, or null if no track
 *     selection needs to be made.
 * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for
 *     downloading.
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers for which tracks
 *     are selected.
 */
public DownloadHelper(
    String downloadType,
    Uri uri,
    @Nullable String cacheKey,
    @Nullable MediaSource mediaSource,
    DefaultTrackSelector.Parameters trackSelectorParameters,
    RendererCapabilities[] rendererCapabilities) {
  this.downloadType = downloadType;
  this.uri = uri;
  this.cacheKey = cacheKey;
  this.mediaSource = mediaSource;
  this.trackSelector = new DefaultTrackSelector(new DownloadTrackSelection.Factory());
  this.rendererCapabilities = rendererCapabilities;
  this.scratchSet = new SparseIntArray();
  trackSelector.setParameters(trackSelectorParameters);
  trackSelector.init(/* listener= */ () -> {}, new DummyBandwidthMeter());
  callbackHandler = new Handler(Util.getLooper());
}
 
Example 4
Source File: RequirementsWatcher.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * @param context Any context.
 * @param listener Notified whether the {@link Requirements} are met.
 * @param requirements The requirements to watch.
 */
public RequirementsWatcher(Context context, Listener listener, Requirements requirements) {
  this.context = context.getApplicationContext();
  this.listener = listener;
  this.requirements = requirements;
  handler = new Handler(Util.getLooper());
}
 
Example 5
Source File: SimpleExoPlayer.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a builder with a custom {@link RenderersFactory}.
 *
 * <p>See {@link #Builder(Context)} for a list of default values.
 *
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer Renderers} to be used by the
 *     player.
 */
public Builder(Context context, RenderersFactory renderersFactory) {
  this(
      context,
      renderersFactory,
      new DefaultTrackSelector(context),
      new DefaultLoadControl(),
      DefaultBandwidthMeter.getSingletonInstance(context),
      Util.getLooper(),
      new AnalyticsCollector(Clock.DEFAULT),
      /* useLazyPreparation= */ true,
      Clock.DEFAULT);
}
 
Example 6
Source File: AudioCapabilitiesReceiver.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * @param context A context for registering the receiver.
 * @param listener The listener to notify when audio capabilities change.
 */
public AudioCapabilitiesReceiver(Context context, Listener listener) {
  context = context.getApplicationContext();
  this.context = context;
  this.listener = Assertions.checkNotNull(listener);
  handler = new Handler(Util.getLooper());
  receiver = Util.SDK_INT >= 21 ? new HdmiAudioPlugBroadcastReceiver() : null;
  Uri externalSurroundSoundUri = AudioCapabilities.getExternalSurroundSoundGlobalSettingUri();
  externalSurroundSoundSettingObserver =
      externalSurroundSoundUri != null
          ? new ExternalSurroundSoundSettingObserver(
              handler, context.getContentResolver(), externalSurroundSoundUri)
          : null;
}
 
Example 7
Source File: ExoFFmpegPlayer.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public ExoFFmpegPlayer(Context context) {

        super(context,
                new SimpleRendersFactory(context),
                new DefaultTrackSelector(),
                new DefaultLoadControl(),
                null,
                new DefaultBandwidthMeter.Builder().build(),
                new AnalyticsCollector.Factory(),
                Clock.DEFAULT,
                Util.getLooper());
    }
 
Example 8
Source File: ExoFFmpegPlayer.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public ExoFFmpegPlayer(Context context, TrackSelector trackSelector) {

        super(context,
                new SimpleRendersFactory(context),
                trackSelector,
                new DefaultLoadControl(),
                null,
                new DefaultBandwidthMeter.Builder().build(),
                new AnalyticsCollector.Factory(),
                Clock.DEFAULT,
                Util.getLooper());
    }
 
Example 9
Source File: RequirementsWatcher.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param context Any context.
 * @param listener Notified whether the {@link Requirements} are met.
 * @param requirements The requirements to watch.
 */
public RequirementsWatcher(Context context, Listener listener, Requirements requirements) {
  this.context = context.getApplicationContext();
  this.listener = listener;
  this.requirements = requirements;
  handler = new Handler(Util.getLooper());
}
 
Example 10
Source File: AudioCapabilitiesReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param context A context for registering the receiver.
 * @param listener The listener to notify when audio capabilities change.
 */
public AudioCapabilitiesReceiver(Context context, Listener listener) {
  context = context.getApplicationContext();
  this.context = context;
  this.listener = Assertions.checkNotNull(listener);
  handler = new Handler(Util.getLooper());
  receiver = Util.SDK_INT >= 21 ? new HdmiAudioPlugBroadcastReceiver() : null;
  Uri externalSurroundSoundUri = AudioCapabilities.getExternalSurroundSoundGlobalSettingUri();
  externalSurroundSoundSettingObserver =
      externalSurroundSoundUri != null
          ? new ExternalSurroundSoundSettingObserver(
              handler, context.getContentResolver(), externalSurroundSoundUri)
          : null;
}
 
Example 11
Source File: RequirementsWatcher.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param context Any context.
 * @param listener Notified whether the {@link Requirements} are met.
 * @param requirements The requirements to watch.
 */
public RequirementsWatcher(Context context, Listener listener, Requirements requirements) {
  this.context = context.getApplicationContext();
  this.listener = listener;
  this.requirements = requirements;
  handler = new Handler(Util.getLooper());
}
 
Example 12
Source File: AudioCapabilitiesReceiver.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param context A context for registering the receiver.
 * @param listener The listener to notify when audio capabilities change.
 */
public AudioCapabilitiesReceiver(Context context, Listener listener) {
  context = context.getApplicationContext();
  this.context = context;
  this.listener = Assertions.checkNotNull(listener);
  handler = new Handler(Util.getLooper());
  receiver = Util.SDK_INT >= 21 ? new HdmiAudioPlugBroadcastReceiver() : null;
  Uri externalSurroundSoundUri = AudioCapabilities.getExternalSurroundSoundGlobalSettingUri();
  externalSurroundSoundSettingObserver =
      externalSurroundSoundUri != null
          ? new ExternalSurroundSoundSettingObserver(
              handler, context.getContentResolver(), externalSurroundSoundUri)
          : null;
}
 
Example 13
Source File: ExoPlayer.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a builder with a list of {@link Renderer Renderers}.
 *
 * <p>The builder uses the following default values:
 *
 * <ul>
 *   <li>{@link TrackSelector}: {@link DefaultTrackSelector}
 *   <li>{@link LoadControl}: {@link DefaultLoadControl}
 *   <li>{@link BandwidthMeter}: {@link DefaultBandwidthMeter#getSingletonInstance(Context)}
 *   <li>{@link Looper}: The {@link Looper} associated with the current thread, or the {@link
 *       Looper} of the application's main thread if the current thread doesn't have a {@link
 *       Looper}
 *   <li>{@link AnalyticsCollector}: {@link AnalyticsCollector} with {@link Clock#DEFAULT}
 *   <li>{@code useLazyPreparation}: {@code true}
 *   <li>{@link Clock}: {@link Clock#DEFAULT}
 * </ul>
 *
 * @param context A {@link Context}.
 * @param renderers The {@link Renderer Renderers} to be used by the player.
 */
public Builder(Context context, Renderer... renderers) {
  this(
      renderers,
      new DefaultTrackSelector(context),
      new DefaultLoadControl(),
      DefaultBandwidthMeter.getSingletonInstance(context),
      Util.getLooper(),
      new AnalyticsCollector(Clock.DEFAULT),
      /* useLazyPreparation= */ true,
      Clock.DEFAULT);
}