Ejemplo n.º 1
0
 public void fetchCover() {
   if (coverCache == null) {
     // spawn thread to fetch coverart
     ThreadExecutor.runTask(
         new Runnable() {
           public void run() {
             try {
               if (screenHeight > 640) {
                 screenHeight = 640;
               }
               // http://192.168.254.128:3689/ctrl-int/1/nowplayingartwork?mw=320&mh=320&session-id=1940361390
               coverCache =
                   RequestHelper.requestBitmap(
                       String.format(
                           "%s/ctrl-int/1/nowplayingartwork?mw="
                               + screenHeight
                               + "&mh="
                               + screenHeight
                               + "&session-id=%s",
                           session.getRequestBase(),
                           session.sessionId));
             } catch (Exception e) {
               Log.e(TAG, "Fetch Cover Exception:" + e.getMessage());
             }
             coverEmpty = (coverCache == null);
             if (update != null) update.sendEmptyMessage(UPDATE_COVER);
           }
         });
   }
 }
Ejemplo n.º 2
0
  // fetch rating of current playing item
  public void fetchRating() {
    // spawn thread to fetch rating
    ThreadExecutor.runTask(
        new Runnable() {
          public void run() {
            try {
              Response resp =
                  RequestHelper.requestParsed(
                      String.format(
                          "%s/databases/%d/items?session-id=%s&meta=daap.songuserrating&type=music&query='dmap.itemid:%d'",
                          session.getRequestBase(), databaseId, session.sessionId, trackId),
                      false);

              if (update != null) {
                // 2 different responses possible!
                Response entry = resp.getNested("adbs"); // iTunes style
                if (entry == null) {
                  entry = resp.getNested("apso"); // MonkeyTunes style
                }
                rating = entry.getNested("mlcl").getNested("mlit").getNumberLong("asur");
                update.sendEmptyMessage(UPDATE_RATING);
              }

            } catch (Exception e) {
              Log.e(TAG, "Fetch Rating Exception:" + e.getMessage());
            }
          }
        });
  }
Ejemplo n.º 3
0
 public void fetchUpdate() {
   Log.d(TAG, "Fetching Update From Server...");
   // force a status update, will pass along to parseUpdate()
   ThreadExecutor.runTask(
       new Runnable() {
         public void run() {
           try {
             // using revision-number=1 will make sure we return
             // instantly
             // http://192.168.254.128:3689/ctrl-int/1/playstatusupdate?revision-number=1&session-id=1034286700
             parseUpdate(
                 RequestHelper.requestParsed(
                     String.format(
                         "%s/ctrl-int/1/playstatusupdate?revision-number=%d&session-id=%s",
                         session.getRequestBase(), 1, session.sessionId),
                     false));
           } catch (Exception e) {
             Log.w(TAG, e);
             if (failures != null && failures.incrementAndGet() > MAX_FAILURES) {
               destroy();
             }
           }
         }
       });
 }