public interface MediaReceivers extends Observable<MediaReceiversEvent>, ProfileService
MediaReceiverDiscovered
Modifier and Type | Method and Description |
---|---|
MediaReceiver |
await(java.util.function.Predicate<MediaReceiver> predicate)
Blocks the current thread until the first receiver matching the
predicate is
discovered. |
MediaReceiver |
await(java.util.function.Predicate<MediaReceiver> predicate,
java.time.Duration timeout)
Blocks the current thread until the first receiver matching the
predicate is
discovered. |
java.util.List<MediaReceiver> |
list()
Returns the list of connected (not unavailable)
media receivers.
|
void |
refresh()
Asynchronously updates the list of available media receivers.
|
on
profile
void refresh()
This method forces Chromium to discover media receivers available in the local network.
Use it before calling the await(Predicate)
method to shorten the time to discover
new receivers.
java.util.List<MediaReceiver> list()
The initial list of media receivers can be empty or not full. This is because receivers are discovered asynchronously in Chromium.
ObjectClosedException
- when the profile is deleted or its engine is closedMediaReceiver await(java.util.function.Predicate<MediaReceiver> predicate)
predicate
is
discovered.
If a matching receiver has already been discovered, returns it immediately.
Example of usage:
browser.set(StartPresentationCallback.class, (params, tell) -> {
params.mediaReceivers().refresh();
MediaReceiver receiver = params.mediaReceivers().await(mediaReceiver -> {
return mediaReceiver.name().startsWith("Samsung TV");
});
tell.start(receiver);
});
predicate
ObjectClosedException
- when the profile is deleted or its engine is closedReceiverNotDiscoveredException
- when the receiver has not been discovered within 45 secondsMediaReceiver await(java.util.function.Predicate<MediaReceiver> predicate, java.time.Duration timeout)
predicate
is
discovered.
If a matching receiver has already been discovered, returns it immediately.
predicate
ObjectClosedException
- when the profile is deleted or its engine is closedReceiverNotDiscoveredException
- when the receiver has not been discovered within timeout