Klasse ChromeCast

java.lang.Object
su.litvak.chromecast.api.v2.ChromeCast

public class ChromeCast extends Object
ChromeCast device - main object used for interaction with ChromeCast dongle.
  • Felddetails

  • Konstruktordetails

    • ChromeCast

      public ChromeCast(String address)
    • ChromeCast

      public ChromeCast(String address, int port)
  • Methodendetails

    • getName

      public final String getName()
      Gibt zurück:
      The technical name of the device. Usually something like Chromecast-e28835678bc02247abcdef112341278f.
    • setName

      public final void setName(String name)
    • getAddress

      public final String getAddress()
      Gibt zurück:
      The IP address of the device.
    • getPort

      public final int getPort()
      Gibt zurück:
      The TCP port number that the device is listening to.
    • getAppsURL

      public final String getAppsURL()
    • setAppsURL

      public final void setAppsURL(String appsURL)
    • getApplication

      public final String getApplication()
      Gibt zurück:
      The mDNS service name. Usually "googlecast".
      Siehe auch:
    • setApplication

      public final void setApplication(String application)
    • getTitle

      public final String getTitle()
      Gibt zurück:
      The name of the device as entered by the person who installed it. Usually something like "Living Room Chromecast".
    • getAppTitle

      public final String getAppTitle()
      Gibt zurück:
      The title of the app that is currently running, or empty string in case of the backdrop. Usually something like "YouTube" or "Spotify", but could also be, say, the URL of a web page being mirrored.
    • getModel

      public final String getModel()
      Gibt zurück:
      The model of the device. Usually "Chromecast" or, if Chromecast is built into your TV, the model of your TV.
    • connect

      public final void connect() throws IOException, GeneralSecurityException
      Löst aus:
      IOException
      GeneralSecurityException
    • disconnect

      public final void disconnect() throws IOException
      Löst aus:
      IOException
    • isConnected

      public final boolean isConnected()
    • setAutoReconnect

      public void setAutoReconnect(boolean autoReconnect)
      Changes behaviour for opening/closing of connection with ChromeCast device. If set to "true" (default value) then connection will be re-established on every request in case it is not present yet, or has been lost. "false" value means manual control over connection with ChromeCast device, i.e. calling connect() or disconnect() methods when needed.
      Parameter:
      autoReconnect - true means controlling connection with ChromeCast device automatically, false - manually
      Siehe auch:
    • isAutoReconnect

      public boolean isAutoReconnect()
      Gibt zurück:
      current value of autoReconnect setting, which controls opening/closing of connection with ChromeCast device
      Siehe auch:
    • setRequestTimeout

      public void setRequestTimeout(long requestTimeout)
      Set up how much time to wait until request is processed (in milliseconds).
      Parameter:
      requestTimeout - value in milliseconds until request times out waiting for response
    • getStatus

      public final Status getStatus() throws IOException
      Gibt zurück:
      current chromecast status - volume, running applications, etc.
      Löst aus:
      IOException
    • getRunningApp

      public final Application getRunningApp() throws IOException
      Gibt zurück:
      descriptor of currently running application
      Löst aus:
      IOException
    • isAppAvailable

      public final boolean isAppAvailable(String appId) throws IOException
      Parameter:
      appId - application identifier
      Gibt zurück:
      true if application is available to this chromecast device, false otherwise
      Löst aus:
      IOException
    • isAppRunning

      public final boolean isAppRunning(String appId) throws IOException
      Parameter:
      appId - application identifier
      Gibt zurück:
      true if application with specified identifier is running now
      Löst aus:
      IOException
    • launchApp

      public final Application launchApp(String appId) throws IOException
      Parameter:
      appId - application identifier
      Gibt zurück:
      application descriptor if app successfully launched, null otherwise
      Löst aus:
      IOException
    • stopApp

      public final void stopApp() throws IOException

      Stops currently running application

      If no application is running at the moment then exception is thrown.

      Löst aus:
      IOException
    • stopSession

      public final void stopSession(String sessionId) throws IOException

      Stops the session with the given identifier.

      Parameter:
      sessionId - session identifier
      Löst aus:
      IOException
    • setVolume

      public final void setVolume(float level) throws IOException
      Parameter:
      level - volume level from 0 to 1 to set
      Löst aus:
      IOException
    • setVolumeByIncrement

      public final void setVolumeByIncrement(float level) throws IOException
      ChromeCast does not allow you to jump levels too quickly to avoid blowing speakers. Setting by increment allows us to easily get the level we want
      Parameter:
      level - volume level from 0 to 1 to set
      Löst aus:
      IOException
      Siehe auch:
    • setMuted

      public final void setMuted(boolean muted) throws IOException
      Parameter:
      muted - is to mute or not
      Löst aus:
      IOException
    • getMediaStatus

      public final MediaStatus getMediaStatus() throws IOException

      If no application is running at the moment then exception is thrown.

      Gibt zurück:
      current media status, state, time, playback rate, etc.
      Löst aus:
      IOException
    • play

      public final void play() throws IOException

      Resume paused media playback

      If no application is running at the moment then exception is thrown.

      Löst aus:
      IOException
    • pause

      public final void pause() throws IOException

      Pause current playback

      If no application is running at the moment then exception is thrown.

      Löst aus:
      IOException
    • seek

      public final void seek(double time) throws IOException

      Moves current playback time point to specified value

      If no application is running at the moment then exception is thrown.

      Parameter:
      time - time point between zero and media duration
      Löst aus:
      IOException
    • load

      public final MediaStatus load(String url) throws IOException

      Loads and starts playing media in specified URL

      If no application is running at the moment then exception is thrown.

      Parameter:
      url - media url
      Gibt zurück:
      The new media status that resulted from loading the media.
      Löst aus:
      IOException
    • load

      public final MediaStatus load(String mediaTitle, String thumb, String url, String contentType) throws IOException

      Loads and starts playing specified media

      If no application is running at the moment then exception is thrown.

      Parameter:
      mediaTitle - name to be displayed
      thumb - url of video thumbnail to be displayed, relative to media url
      url - media url
      contentType - MIME content type
      Gibt zurück:
      The new media status that resulted from loading the media.
      Löst aus:
      IOException
    • load

      public final MediaStatus load(Media media) throws IOException

      Loads and starts playing specified media

      If no application is running at the moment then exception is thrown.

      Parameter:
      media - The media to load and play. See https://developers.google.com/cast/docs/reference/messages#Load for more details.
      Gibt zurück:
      The new media status that resulted from loading the media.
      Löst aus:
      IOException
    • send

      public final <T extends Response> T send(String namespace, Request request, Class<T> responseClass) throws IOException

      Sends some generic request to the currently running application.

      If no application is running at the moment then exception is thrown.

      Typparameter:
      T - type of response
      Parameter:
      namespace - request namespace
      request - request object
      responseClass - class of the response for proper deserialization
      Gibt zurück:
      deserialized response
      Löst aus:
      IOException
    • send

      public final void send(String namespace, Request request) throws IOException

      Sends some generic request to the currently running application. No response is expected as a result of this call.

      If no application is running at the moment then exception is thrown.

      Parameter:
      namespace - request namespace
      request - request object
      Löst aus:
      IOException
    • registerListener

      public final void registerListener(ChromeCastSpontaneousEventListener listener)
    • unregisterListener

      public final void unregisterListener(ChromeCastSpontaneousEventListener listener)
    • registerConnectionListener

      public final void registerConnectionListener(ChromeCastConnectionEventListener listener)
    • unregisterConnectionListener

      public final void unregisterConnectionListener(ChromeCastConnectionEventListener listener)
    • toString

      public final String toString()
      Setzt außer Kraft:
      toString in Klasse Object