Interface MediaReceivers

All Superinterfaces:
Observable<MediaReceiversEvent>, ProfileService

public interface MediaReceivers extends Observable<MediaReceiversEvent>, ProfileService
A service that allows observing media receivers in the environment.
Since:
7.29
See Also:
  • 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

      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 the 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);
       });
       
       
      Returns:
      the first discovered receiver matching the predicate
      Throws:
      ObjectClosedException - when the profile is deleted or its engine is closed
      ReceiverNotDiscoveredException - when the receiver has not been discovered within 45 seconds
    • await

      MediaReceiver await(Predicate<MediaReceiver> predicate, Duration timeout)
      Blocks the current thread until the first receiver matching the predicate is 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 closed
      ReceiverNotDiscoveredException - when the receiver has not been discovered within timeout