Package com.teamdev.jxbrowser.cast
Interface MediaReceivers
- All Superinterfaces:
Observable<MediaReceiversEvent>,ProfileService
A service that allows observing media receivers in the environment.
- Since:
- 7.29
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionawait(Predicate<MediaReceiver> predicate) Blocks the current thread until the first receiver matching thepredicateis discovered.await(Predicate<MediaReceiver> predicate, Duration timeout) Blocks the current thread until the first receiver matching thepredicateis discovered.list()Returns the list of connected (not unavailable) media receivers.voidrefresh()Asynchronously updates the list of available media receivers.Methods inherited from interface com.teamdev.jxbrowser.event.Observable
onMethods inherited from interface com.teamdev.jxbrowser.profile.ProfileService
profile
-
Method Details
-
refresh
void refresh()Asynchronously updates the list of available media receivers.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.- Since:
- 7.34
-
list
List<MediaReceiver> list()Returns the list of connected (not unavailable) media receivers.The initial list of media receivers can be empty or not full. This is because receivers are discovered asynchronously in Chromium.
- Throws:
ObjectClosedException- when the profile is deleted or its engine is closed
-
await
Blocks the current thread until the first receiver matching thepredicateis 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); });- Returns:
- the first discovered receiver matching the
predicate - Throws:
ObjectClosedException- when the profile is deleted or its engine is closedReceiverNotDiscoveredException- when the receiver has not been discovered within 45 seconds
-
await
Blocks the current thread until the first receiver matching thepredicateis discovered.If a matching receiver has already been discovered, returns it immediately.
- Returns:
- the first discovered receiver matching the
predicate - Throws:
ObjectClosedException- when the profile is deleted or its engine is closedReceiverNotDiscoveredException- when the receiver has not been discovered withintimeout
-