public void dlnaStop() {
    if (!messageQueue.inThread()) {
      throw new RuntimeException("stop must run on MediaPlayerService handler Thread");
    }
    try {
      LogManager.d(TAG, "dlna-----stop");
      reset();
      mMediaPlayer.reset();

    } catch (Exception e) {
      LogManager.printStackTrace(e);
    }
  }
  public void release() {
    if (!messageQueue.inThread()) {
      throw new RuntimeException("release must run on MediaPlayerService handler Thread");
    }

    try {
      if (mMediaPlayer != null) {
        LogManager.d(TAG, "release()");
        mMediaPlayer.release();
        reset();
      }
    } catch (IllegalStateException e) {
      LogManager.printStackTrace(e);
    } catch (Exception e) {
      LogManager.printStackTrace(e);
    }
  }
 // 取消声音渐变的
 public void simplePause() {
   if (!messageQueue.inThread()) {
     throw new RuntimeException("simplePause must run on MediaPlayerService handler Thread");
   }
   try {
     if (mMediaPlayer != null) {
       if (hasReady) {
         LogManager.d(TAG, "simplePause()");
         mMediaPlayer.setVolume(1, 1);
         mMediaPlayer.pause();
       } else {
         LogManager.d(TAG, "simplePause() is ignore! mediaPlayer is not ready");
       }
     }
   } catch (IllegalStateException e) {
     LogManager.printStackTrace(e);
   } catch (Exception e) {
     LogManager.printStackTrace(e);
   }
 }
  public void pause() {
    if (!messageQueue.inThread()) {
      throw new RuntimeException("pause must run on MediaPlayerService handler Thread");
    }
    try {
      if (mMediaPlayer != null) {
        if (hasReady) {
          LogManager.i(TAG, "onpause()");
          // 声音渐出
          MediaPlayerUtil.autoIncreaseVloume(context, mMediaPlayer, false);

          mMediaPlayer.pause();
        } else {
          LogManager.i(TAG, "onpause() is ignore! mediaPlayer is not ready");
        }
      }
    } catch (IllegalStateException e) {
      LogManager.printStackTrace(e);
    } catch (Exception e) {
      LogManager.printStackTrace(e);
    }
  }
 public void seekTo(int pos) {
   if (!messageQueue.inThread()) {
     throw new RuntimeException("seekTo must run on MediaPlayerService handler Thread");
   }
   try {
     if (mMediaPlayer != null) {
       if (hasReady) {
         int d = getDuration();
         if (pos <= d) {
           LogManager.d(TAG, "seekTo (" + pos + ")");
         } else {
           LogManager.d(TAG, "seekTo error pos > Duration :" + pos + "/" + d + ")");
         }
         mMediaPlayer.seekTo(pos);
       } else {
         LogManager.d(TAG, "seekTo(" + pos + ") is ignore! mediaPlayer is not ready");
       }
     }
   } catch (IllegalStateException e) {
     LogManager.printStackTrace(e);
   } catch (Exception e) {
     LogManager.printStackTrace(e);
   }
 }
  // ****************操作命令****************** //
  public void setMediaInfoList(String path) {
    if (!messageQueue.inThread()) {
      throw new RuntimeException("setMediaInfoList must run on MediaPlayerService handler Thread");
    }
    try {
      LogManager.d(TAG, "setMediaInfoList", "set Path:" + path);
      // 复用播放器
      hasReady = false;
      mMediaPlayer.reset();

      if (mBaseContext.getPrefBoolean(KeyList.PKEY_CUREENT_MUSIC_IS_DLAN, false)) {
        LogManager.d(TAG, "setMediaInfoList dlan音乐");
        mMediaPlayer.setDataSource(path);
        mMediaPlayer.prepareAsync();
        mMediaPlayer.setOnPreparedListener(
            new OnPreparedListener() {

              @Override
              public void onPrepared(MediaPlayer mp) {
                // TODO Auto-generated method stub
                if (preparedListener != null) {
                  preparedListener.onPrepared(mp);
                }
              }
            });
        // 统计第三方协议播放
        mBaseContext.sendUmengEvent(
            UmengUtil.THE_THIRD_PROTOCOL_PLAY, UmengUtil.THE_THIRD_PROTOCOL_PLAY_CONTENT);
      } else if (path.startsWith("http")) {
        LogManager.d(TAG, "setMediaInfoList 代理音乐");

        String localMusicCache = HttpGetProxyUtils.getLocalOrCacheMusicsPath(path);
        if (localMusicCache != null) {
          mMediaPlayer.setDataSource(localMusicCache);
        } else {
          String mypath = HttpProxy.proxyHttpUrl + path;
          mMediaPlayer.setDataSource(mypath);
        }
      } else {
        LogManager.d(TAG, "setMediaInfoList 普通音乐");
        if (path.startsWith(MusicInfoManager.MUSIC_SAVE_POSE)) {
          int currentLocalMusicId =
              Integer.parseInt(path.replace(MusicInfoManager.MUSIC_SAVE_POSE, ""));
          // 记录当前歌曲ID
          mBaseContext.setPrefInteger(KeyList.CURRENT_LOCAL_MUSIC_ID, currentLocalMusicId);
        }
        mMediaPlayer.setDataSource(path);
      }

      if (!mBaseContext.getPrefBoolean(KeyList.PKEY_CUREENT_MUSIC_IS_DLAN, false)) {
        mMediaPlayer.prepare();
      }

      // 阻塞播放器
      hasReady = true;
    } catch (IOException e) {
      LogManager.printStackTrace(e, "MediaPlayerService", "setMediaInfoList");
      LogManager.e("path:" + path + " is invaild!");
      // 无法复用播放器
      hasReady = false;
      try {
        if (onErrorListener != null) {
          onErrorListener.onError(mMediaPlayer, MEDIA_ERROR_TRY, currentPosition);
        }
      } catch (IllegalStateException e1) {
        LogManager.printStackTrace(e1);
      } catch (Exception e1) {
        LogManager.printStackTrace(e1);
      }
    } catch (Exception e) {
      LogManager.printStackTrace(e, "MediaPlayerService", "setMediaInfoList");
    }
  }