Exemplo n.º 1
0
  private void joinSession(RouteInfo routeInfo) {
    ChromecastSession sessionJoinAttempt =
        new ChromecastSession(routeInfo, this.cordova, this, this);
    sessionJoinAttempt.join(
        this.appId,
        this.lastSessionId,
        new ChromecastSessionCallback() {

          @Override
          void onSuccess(Object object) {
            if (Chromecast.this.currentSession == null) {
              try {
                Chromecast.this.currentSession = (ChromecastSession) object;
                Chromecast.this.setLastSessionId(Chromecast.this.currentSession.getSessionId());
                sendJavascript(
                    "chrome.cast._.sessionJoined("
                        + Chromecast.this.currentSession.createSessionObject().toString()
                        + ");");
              } catch (Exception e) {
                log("wut.... " + e.getMessage() + e.getStackTrace());
              }
            }
          }

          @Override
          void onError(String reason) {
            log("sessionJoinAttempt error " + reason);
          }
        });
  }
Exemplo n.º 2
0
 /**
  * Pause on the current media in the current session
  *
  * @param callbackContext
  * @return
  */
 public boolean mediaPause(CallbackContext callbackContext) {
   if (currentSession != null) {
     currentSession.mediaPause(genericCallback(callbackContext));
   } else {
     callbackContext.error("session_error");
   }
   return true;
 }
Exemplo n.º 3
0
  /**
   * Set the muted on the media
   *
   * @param muted
   * @param callbackContext
   * @return
   */
  public boolean setMediaMuted(Boolean muted, CallbackContext callbackContext) {
    if (currentSession != null) {
      currentSession.mediaSetMuted(muted, genericCallback(callbackContext));
    } else {
      callbackContext.error("session_error");
    }

    return true;
  }
Exemplo n.º 4
0
  /**
   * Set the volume on the media
   *
   * @param level
   * @param callbackContext
   * @return
   */
  public boolean setMediaVolume(Double level, CallbackContext callbackContext) {
    if (currentSession != null) {
      currentSession.mediaSetVolume(level, genericCallback(callbackContext));
    } else {
      callbackContext.error("session_error");
    }

    return true;
  }
Exemplo n.º 5
0
 /**
  * Seeks the current media in the current session
  *
  * @param seekTime
  * @param resumeState
  * @param callbackContext
  * @return
  */
 public boolean mediaSeek(Integer seekTime, String resumeState, CallbackContext callbackContext) {
   if (currentSession != null) {
     currentSession.mediaSeek(
         seekTime.longValue() * 1000, resumeState, genericCallback(callbackContext));
   } else {
     callbackContext.error("session_error");
   }
   return true;
 }
Exemplo n.º 6
0
 @Override
 public void onMessage(ChromecastSession session, String namespace, String message) {
   sendJavascript(
       "chrome.cast._.onMessage('"
           + session.getSessionId()
           + "', '"
           + namespace
           + "', '"
           + message
           + "')");
 }