Class PushSource

java.lang.Object
lol.trq.orpheus.source.PushSource
All Implemented Interfaces:
Source, Transport

public final class PushSource extends Object implements Source, Transport
A source fed by the program itself: publish what your own player is doing and register handlers for the commands it accepts. Thread-safe. Sessions of a push source are always visible.
  • Method Details

    • create

      public static PushSource create(String id)
    • create

      public static PushSource create(String id, String name)
      Creates a source with a separate display name.
    • id

      public String id()
      Description copied from interface: Source
      A short stable name, unique among the sources of one Orpheus.
      Specified by:
      id in interface Source
    • publish

      public void publish(PlaybackUpdate update)
      Publishes the current state. Publish again whenever something changes, including after a seek.
    • clear

      public void clear()
      Removes the session, as when the player closes.
    • handler

      public PushSource handler(Control control, Consumer<ControlRequest> handler)
      Registers what to do for a command. The handler runs on a library thread and must return quickly; throwing reports the command as failed. The control is advertised at once.
    • responder

      public PushSource responder(Control control, Function<ControlRequest, CompletableFuture<ControlResult>> responder)
      Like handler(Control, Consumer), for a player that can refuse a command or answers later: the function returns the outcome, now or when it is known.
    • provide

      public <T> PushSource provide(Class<T> type, T implementation)
      Offers an extra ability such as QueueAccess, Devices or LibraryAccess.
    • capability

      public <T> T capability(Class<T> type)
      Description copied from interface: Source
      The ability of the given type, or null when this source does not have it.
      Specified by:
      capability in interface Source
    • start

      public void start(SourceSink newSink)
      Description copied from interface: Source
      Starts reporting to sink. Returns quickly; failures are reported as a status, not thrown.
      Specified by:
      start in interface Source
    • stop

      public void stop()
      Description copied from interface: Source
      Stops and releases every thread, handle and process. Safe to call twice and before start.
      Specified by:
      stop in interface Source
    • send

      Description copied from interface: Transport
      Sends a command. Never throws and never blocks; the future always completes.
      Specified by:
      send in interface Transport