Beispiel #1
0
        @Override
        public boolean onError(MediaPlayer player, int whatError, int extra) {
          Logger.LOGD(TAG, "onError called: " + "(" + whatError + "," + extra + ")");
          if (mRunMode == Configer.RunMode.MODE_DIRECT && whatError != -38) {
            onExitProc();
            return true;
          }

          switch (whatError) {
            case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
              // initPlayer();
              Logger.LOGD("Play Error:::", "MEDIA_ERROR_SERVER_DIED");
              onExitProc();
              break;
            default:
              PlayItemEntity pie = mData.get(mCurClickPos);
              if (pie.getUrlList() != null && ((mPlayingIdx + 1) < pie.getUrlList().size())) {
                Logger.LOGD("begin to alter source");
                mPlayingIdx++;
                myPlay(mCurClickPos);
              } else {
                next(true);
              }
              break;
          }
          return true;
        }
Beispiel #2
0
  public void myPlay(int curClickPos) {
    if (curClickPos == -1) curClickPos = 0;

    mCurClickPos = curClickPos;
    if (mData == null || curClickPos >= mData.size()) return;

    String purl = null;
    String src = "";
    PlayItemEntity pie = mData.get(curClickPos);
    if (mRunMode == Configer.RunMode.MODE_LOCAL) {
      // purl = pie.getDownUrl();
      try {
        purl = pie.getUrlList().get(0).getUrl();
      } catch (Exception e) {
        purl = "";
      }
      //			if(purl != null)
      //				purl = URLEncoder.encode(purl);
    } else {
      long ts = System.currentTimeMillis();
      UrlInfoEntry u = pie.getUrlList().get(mPlayingIdx);
      src = URLEncoder.encode(u.getSrc());
      String idx = u.getUrl();

      purl =
          Configer.initUrl(Configer.REQ_PLAYURL)
              + pie.getIds()
              + "/"
              + src
              + "/"
              + idx
              + "/"
              + ts
              + "/"
              + MyUtil.getSign(ts);
    }

    if (purl == null || (mPlayPath != null && mPlayPath.compareTo(purl) == 0)) return;

    mPlayPath = purl;
    myPlay(mPlayPath, src);
  }