Java Code Examples for com.google.android.exoplayer2.util.Util#createHandler()
The following examples show how to use
com.google.android.exoplayer2.util.Util#createHandler() .
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: TextRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param output The output. * @param outputLooper The looper associated with the thread on which the output should be called. * If the output makes use of standard Android UI components, then this should normally be the * looper associated with the application's main thread, which can be obtained using {@link * android.app.Activity#getMainLooper()}. Null may be passed if the output should be called * directly on the player's internal rendering thread. * @param decoderFactory A factory from which to obtain {@link SubtitleDecoder} instances. */ public TextRenderer( TextOutput output, @Nullable Looper outputLooper, SubtitleDecoderFactory decoderFactory) { super(C.TRACK_TYPE_TEXT); this.output = Assertions.checkNotNull(output); this.outputHandler = outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this); this.decoderFactory = decoderFactory; formatHolder = new FormatHolder(); }
Example 2
Source File: VideoFrameReleaseTimeHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private VSyncSampler() { sampledVsyncTimeNs = C.TIME_UNSET; choreographerOwnerThread = new HandlerThread("ChoreographerOwner:Handler"); choreographerOwnerThread.start(); handler = Util.createHandler(choreographerOwnerThread.getLooper(), /* callback= */ this); handler.sendEmptyMessage(CREATE_CHOREOGRAPHER); }
Example 3
Source File: DownloadManager.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Constructs a {@link DownloadManager}. * * @param context Any context. * @param downloadIndex The download index used to hold the download information. * @param downloaderFactory A factory for creating {@link Downloader}s. */ public DownloadManager( Context context, WritableDownloadIndex downloadIndex, DownloaderFactory downloaderFactory) { this.context = context.getApplicationContext(); this.downloadIndex = downloadIndex; maxParallelDownloads = DEFAULT_MAX_PARALLEL_DOWNLOADS; minRetryCount = DEFAULT_MIN_RETRY_COUNT; downloadsPaused = true; downloads = Collections.emptyList(); listeners = new CopyOnWriteArraySet<>(); @SuppressWarnings("methodref.receiver.bound.invalid") Handler mainHandler = Util.createHandler(this::handleMainMessage); this.mainHandler = mainHandler; HandlerThread internalThread = new HandlerThread("DownloadManager file i/o"); internalThread.start(); internalHandler = new InternalHandler( internalThread, downloadIndex, downloaderFactory, mainHandler, maxParallelDownloads, minRetryCount, downloadsPaused); @SuppressWarnings("methodref.receiver.bound.invalid") RequirementsWatcher.Listener requirementsListener = this::onRequirementsStateChanged; this.requirementsListener = requirementsListener; requirementsWatcher = new RequirementsWatcher(context, requirementsListener, DEFAULT_REQUIREMENTS); notMetRequirements = requirementsWatcher.start(); pendingMessages = 1; internalHandler .obtainMessage(MSG_INITIALIZE, notMetRequirements, /* unused */ 0) .sendToTarget(); }
Example 4
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public MediaPreparer(MediaSource mediaSource, DownloadHelper downloadHelper) { this.mediaSource = mediaSource; this.downloadHelper = downloadHelper; allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE); pendingMediaPeriods = new ArrayList<>(); @SuppressWarnings("methodref.receiver.bound.invalid") Handler downloadThreadHandler = Util.createHandler(this::handleDownloadHelperCallbackMessage); this.downloadHelperHandler = downloadThreadHandler; mediaSourceThread = new HandlerThread("DownloadHelper"); mediaSourceThread.start(); mediaSourceHandler = Util.createHandler(mediaSourceThread.getLooper(), /* callback= */ this); mediaSourceHandler.sendEmptyMessage(MESSAGE_PREPARE_SOURCE); }
Example 5
Source File: DownloadManager.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Constructs a {@link DownloadManager}. * * @param context Any context. * @param downloadIndex The download index used to hold the download information. * @param downloaderFactory A factory for creating {@link Downloader}s. */ public DownloadManager( Context context, WritableDownloadIndex downloadIndex, DownloaderFactory downloaderFactory) { this.context = context.getApplicationContext(); this.downloadIndex = downloadIndex; maxParallelDownloads = DEFAULT_MAX_PARALLEL_DOWNLOADS; minRetryCount = DEFAULT_MIN_RETRY_COUNT; downloadsPaused = true; downloads = Collections.emptyList(); listeners = new CopyOnWriteArraySet<>(); @SuppressWarnings("methodref.receiver.bound.invalid") Handler mainHandler = Util.createHandler(this::handleMainMessage); this.mainHandler = mainHandler; HandlerThread internalThread = new HandlerThread("DownloadManager file i/o"); internalThread.start(); internalHandler = new InternalHandler( internalThread, downloadIndex, downloaderFactory, mainHandler, maxParallelDownloads, minRetryCount, downloadsPaused); @SuppressWarnings("methodref.receiver.bound.invalid") RequirementsWatcher.Listener requirementsListener = this::onRequirementsStateChanged; this.requirementsListener = requirementsListener; requirementsWatcher = new RequirementsWatcher(context, requirementsListener, DEFAULT_REQUIREMENTS); notMetRequirements = requirementsWatcher.start(); pendingMessages = 1; internalHandler .obtainMessage(MSG_INITIALIZE, notMetRequirements, /* unused */ 0) .sendToTarget(); }
Example 6
Source File: MetadataRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * @param output The output. * @param outputLooper The looper associated with the thread on which the output should be called. * If the output makes use of standard Android UI components, then this should normally be the * looper associated with the application's main thread, which can be obtained using {@link * android.app.Activity#getMainLooper()}. Null may be passed if the output should be called * directly on the player's internal rendering thread. * @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances. */ public MetadataRenderer( MetadataOutput output, @Nullable Looper outputLooper, MetadataDecoderFactory decoderFactory) { super(C.TRACK_TYPE_METADATA); this.output = Assertions.checkNotNull(output); this.outputHandler = outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this); this.decoderFactory = Assertions.checkNotNull(decoderFactory); formatHolder = new FormatHolder(); buffer = new MetadataInputBuffer(); pendingMetadata = new Metadata[MAX_PENDING_METADATA_COUNT]; pendingMetadataTimestamps = new long[MAX_PENDING_METADATA_COUNT]; }
Example 7
Source File: TextRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * @param output The output. * @param outputLooper The looper associated with the thread on which the output should be called. * If the output makes use of standard Android UI components, then this should normally be the * looper associated with the application's main thread, which can be obtained using {@link * android.app.Activity#getMainLooper()}. Null may be passed if the output should be called * directly on the player's internal rendering thread. * @param decoderFactory A factory from which to obtain {@link SubtitleDecoder} instances. */ public TextRenderer( TextOutput output, @Nullable Looper outputLooper, SubtitleDecoderFactory decoderFactory) { super(C.TRACK_TYPE_TEXT); this.output = Assertions.checkNotNull(output); this.outputHandler = outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this); this.decoderFactory = decoderFactory; formatHolder = new FormatHolder(); }
Example 8
Source File: VideoFrameReleaseTimeHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
private VSyncSampler() { sampledVsyncTimeNs = C.TIME_UNSET; choreographerOwnerThread = new HandlerThread("ChoreographerOwner:Handler"); choreographerOwnerThread.start(); handler = Util.createHandler(choreographerOwnerThread.getLooper(), /* callback= */ this); handler.sendEmptyMessage(CREATE_CHOREOGRAPHER); }
Example 9
Source File: PlayerEmsgHandler.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param manifest The initial manifest. * @param playerEmsgCallback The callback that this event handler can invoke when handling emsg * messages that generate DASH media source events. * @param allocator An {@link Allocator} from which allocations can be obtained. */ public PlayerEmsgHandler( DashManifest manifest, PlayerEmsgCallback playerEmsgCallback, Allocator allocator) { this.manifest = manifest; this.playerEmsgCallback = playerEmsgCallback; this.allocator = allocator; manifestPublishTimeToExpiryTimeUs = new TreeMap<>(); handler = Util.createHandler(/* callback= */ this); decoder = new EventMessageDecoder(); lastLoadedChunkEndTimeUs = C.TIME_UNSET; lastLoadedChunkEndTimeBeforeRefreshUs = C.TIME_UNSET; }
Example 10
Source File: MetadataRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param output The output. * @param outputLooper The looper associated with the thread on which the output should be called. * If the output makes use of standard Android UI components, then this should normally be the * looper associated with the application's main thread, which can be obtained using {@link * android.app.Activity#getMainLooper()}. Null may be passed if the output should be called * directly on the player's internal rendering thread. * @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances. */ public MetadataRenderer( MetadataOutput output, @Nullable Looper outputLooper, MetadataDecoderFactory decoderFactory) { super(C.TRACK_TYPE_METADATA); this.output = Assertions.checkNotNull(output); this.outputHandler = outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this); this.decoderFactory = Assertions.checkNotNull(decoderFactory); formatHolder = new FormatHolder(); buffer = new MetadataInputBuffer(); pendingMetadata = new Metadata[MAX_PENDING_METADATA_COUNT]; pendingMetadataTimestamps = new long[MAX_PENDING_METADATA_COUNT]; }
Example 11
Source File: MetadataRenderer.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * @param output The output. * @param outputLooper The looper associated with the thread on which the output should be called. * If the output makes use of standard Android UI components, then this should normally be the * looper associated with the application's main thread, which can be obtained using {@link * android.app.Activity#getMainLooper()}. Null may be passed if the output should be called * directly on the player's internal rendering thread. * @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances. */ public MetadataRenderer( MetadataOutput output, @Nullable Looper outputLooper, MetadataDecoderFactory decoderFactory) { super(C.TRACK_TYPE_METADATA); this.output = Assertions.checkNotNull(output); this.outputHandler = outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this); this.decoderFactory = Assertions.checkNotNull(decoderFactory); formatHolder = new FormatHolder(); buffer = new MetadataInputBuffer(); pendingMetadata = new Metadata[MAX_PENDING_METADATA_COUNT]; pendingMetadataTimestamps = new long[MAX_PENDING_METADATA_COUNT]; }
Example 12
Source File: PlayerEmsgHandler.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * @param manifest The initial manifest. * @param playerEmsgCallback The callback that this event handler can invoke when handling emsg * messages that generate DASH media source events. * @param allocator An {@link Allocator} from which allocations can be obtained. */ public PlayerEmsgHandler( DashManifest manifest, PlayerEmsgCallback playerEmsgCallback, Allocator allocator) { this.manifest = manifest; this.playerEmsgCallback = playerEmsgCallback; this.allocator = allocator; manifestPublishTimeToExpiryTimeUs = new TreeMap<>(); handler = Util.createHandler(/* callback= */ this); decoder = new EventMessageDecoder(); lastLoadedChunkEndTimeUs = C.TIME_UNSET; lastLoadedChunkEndTimeBeforeRefreshUs = C.TIME_UNSET; }
Example 13
Source File: PlayerEmsgHandler.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param manifest The initial manifest. * @param playerEmsgCallback The callback that this event handler can invoke when handling emsg * messages that generate DASH media source events. * @param allocator An {@link Allocator} from which allocations can be obtained. */ public PlayerEmsgHandler( DashManifest manifest, PlayerEmsgCallback playerEmsgCallback, Allocator allocator) { this.manifest = manifest; this.playerEmsgCallback = playerEmsgCallback; this.allocator = allocator; manifestPublishTimeToExpiryTimeUs = new TreeMap<>(); handler = Util.createHandler(/* callback= */ this); decoder = new EventMessageDecoder(); lastLoadedChunkEndTimeUs = C.TIME_UNSET; lastLoadedChunkEndTimeBeforeRefreshUs = C.TIME_UNSET; }
Example 14
Source File: MetadataRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param output The output. * @param outputLooper The looper associated with the thread on which the output should be called. * If the output makes use of standard Android UI components, then this should normally be the * looper associated with the application's main thread, which can be obtained using {@link * android.app.Activity#getMainLooper()}. Null may be passed if the output should be called * directly on the player's internal rendering thread. * @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances. */ public MetadataRenderer( MetadataOutput output, @Nullable Looper outputLooper, MetadataDecoderFactory decoderFactory) { super(C.TRACK_TYPE_METADATA); this.output = Assertions.checkNotNull(output); this.outputHandler = outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this); this.decoderFactory = Assertions.checkNotNull(decoderFactory); formatHolder = new FormatHolder(); buffer = new MetadataInputBuffer(); pendingMetadata = new Metadata[MAX_PENDING_METADATA_COUNT]; pendingMetadataTimestamps = new long[MAX_PENDING_METADATA_COUNT]; }
Example 15
Source File: TextRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param output The output. * @param outputLooper The looper associated with the thread on which the output should be called. * If the output makes use of standard Android UI components, then this should normally be the * looper associated with the application's main thread, which can be obtained using {@link * android.app.Activity#getMainLooper()}. Null may be passed if the output should be called * directly on the player's internal rendering thread. * @param decoderFactory A factory from which to obtain {@link SubtitleDecoder} instances. */ public TextRenderer( TextOutput output, @Nullable Looper outputLooper, SubtitleDecoderFactory decoderFactory) { super(C.TRACK_TYPE_TEXT); this.output = Assertions.checkNotNull(output); this.outputHandler = outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this); this.decoderFactory = decoderFactory; formatHolder = new FormatHolder(); }
Example 16
Source File: VideoFrameReleaseTimeHelper.java From MediaSDK with Apache License 2.0 | 5 votes |
private VSyncSampler() { sampledVsyncTimeNs = C.TIME_UNSET; choreographerOwnerThread = new HandlerThread("ChoreographerOwner:Handler"); choreographerOwnerThread.start(); handler = Util.createHandler(choreographerOwnerThread.getLooper(), /* callback= */ this); handler.sendEmptyMessage(CREATE_CHOREOGRAPHER); }
Example 17
Source File: TextRenderer.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * @param output The output. * @param outputLooper The looper associated with the thread on which the output should be called. * If the output makes use of standard Android UI components, then this should normally be the * looper associated with the application's main thread, which can be obtained using {@link * android.app.Activity#getMainLooper()}. Null may be passed if the output should be called * directly on the player's internal rendering thread. * @param decoderFactory A factory from which to obtain {@link SubtitleDecoder} instances. */ public TextRenderer( TextOutput output, @Nullable Looper outputLooper, SubtitleDecoderFactory decoderFactory) { super(C.TRACK_TYPE_TEXT); this.output = Assertions.checkNotNull(output); this.outputHandler = outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this); this.decoderFactory = decoderFactory; formatHolder = new FormatHolder(); }
Example 18
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 5 votes |
public MediaPreparer(MediaSource mediaSource, DownloadHelper downloadHelper) { this.mediaSource = mediaSource; this.downloadHelper = downloadHelper; allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE); pendingMediaPeriods = new ArrayList<>(); @SuppressWarnings("methodref.receiver.bound.invalid") Handler downloadThreadHandler = Util.createHandler(this::handleDownloadHelperCallbackMessage); this.downloadHelperHandler = downloadThreadHandler; mediaSourceThread = new HandlerThread("DownloadHelper"); mediaSourceThread.start(); mediaSourceHandler = Util.createHandler(mediaSourceThread.getLooper(), /* callback= */ this); mediaSourceHandler.sendEmptyMessage(MESSAGE_PREPARE_SOURCE); }
Example 19
Source File: PlayerEmsgHandler.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * @param manifest The initial manifest. * @param playerEmsgCallback The callback that this event handler can invoke when handling emsg * messages that generate DASH media source events. * @param allocator An {@link Allocator} from which allocations can be obtained. */ public PlayerEmsgHandler( DashManifest manifest, PlayerEmsgCallback playerEmsgCallback, Allocator allocator) { this.manifest = manifest; this.playerEmsgCallback = playerEmsgCallback; this.allocator = allocator; manifestPublishTimeToExpiryTimeUs = new TreeMap<>(); handler = Util.createHandler(/* callback= */ this); decoder = new EventMessageDecoder(); lastLoadedChunkEndTimeUs = C.TIME_UNSET; lastLoadedChunkEndTimeBeforeRefreshUs = C.TIME_UNSET; }
Example 20
Source File: DownloadHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
public MediaPreparer(MediaSource mediaSource, DownloadHelper downloadHelper) { this.mediaSource = mediaSource; this.downloadHelper = downloadHelper; allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE); pendingMediaPeriods = new ArrayList<>(); @SuppressWarnings("methodref.receiver.bound.invalid") Handler downloadThreadHandler = Util.createHandler(this::handleDownloadHelperCallbackMessage); this.downloadHelperHandler = downloadThreadHandler; mediaSourceThread = new HandlerThread("DownloadHelper"); mediaSourceThread.start(); mediaSourceHandler = Util.createHandler(mediaSourceThread.getLooper(), /* callback= */ this); mediaSourceHandler.sendEmptyMessage(MESSAGE_PREPARE_SOURCE); }