private void DownMusic(Music music) {
   // 创建新的下载任务
   music.setSavePath(
       dir.getAbsolutePath()
           + music.getMusicPath().substring(music.getMusicPath().lastIndexOf("/")));
   // 通过binder对象,向service的任务队列添加新任务
   binder.addTask(music);
 }
  /* 分享选中的音乐 */
  private void ShareMusicFile() {

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("audio/*");
    File file = new File(music.getMusicName());
    Uri u = Uri.fromFile(file);
    intent.putExtra(Intent.EXTRA_STREAM, u);
    System.out.println(music.getMusicName());
    intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
    intent.putExtra(Intent.EXTRA_TEXT, "当前被分享歌曲:" + music.getMusicName() + "(用户通过魔乐盒分享了一首歌曲)");
    startActivity(Intent.createChooser(intent, getTitle()));
    return;
  }
 public void ShowNowPlayMusic() {
   Music music = MyApplication.musics.get(position);
   if (music != null) {
     nowbitmap = BitmapTool.getbitBmBykey(context, music.getAlbumkey());
     if (nowbitmap != null && nowbitmap.isRecycled() == false) {
       list_show_album.setImageBitmap(nowbitmap);
     } else {
       list_show_album.setImageResource(R.drawable.default_bg_s);
     }
     tvsongname.setText(music.getMusicName());
     tvdurction.setText("00:00/" + StrTime.getTime(music.getTime()));
   }
 }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    if (item.getGroupId() == 1) { // 远程音乐
      AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
      final Music music = (Music) netLayout.netlistview.getAdapter().getItem(menuInfo.position);
      switch (item.getItemId()) {
        case MENU_DOWN_MUSIC:
          netLayout.Refresh(NetLayout.DOWN_MUSIC, menuInfo.position);
          if (!music.isLoaded()) {
            DownMusic(music);
          } else {
            AlertDialog.Builder builder = new Builder(context);
            builder
                .setTitle("注意")
                .setMessage("音乐已经存在确认要重复下载吗?")
                .setPositiveButton(
                    "确定",
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        DownMusic(music);
                      }
                    })
                .setNegativeButton("取消", null)
                .create()
                .show();
          }
          break;
        case MENU_LISTEN_MUSIC:
          progressDialog = new ProgressDialog(MainActivity.this);
          progressDialog.setMessage("音乐正在缓冲中,请等待......");
          progressDialog.show();
          Intent intent = new Intent(Constant.ACTION_NET_PLAY);
          intent.putExtra("net_music", music);
          sendBroadcast(intent);
          netLayout.Refresh(NetLayout.LISTEN_MUSIC, menuInfo.position);
          break;
      }
    } else if (item.getGroupId() == 0) {
      // 获得menuinfo对象
      ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
      // 获得一个packedPosition
      long packedPosition = info.packedPosition;
      // 根据packedPosition,获取Expandablelistview中被选中项的groupPosition
      // 组id
      int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
      // childid
      int childPosition = ExpandableListView.getPackedPositionChild(packedPosition);
      // 获取组对象
      MusicGroup group =
          (MusicGroup)
              favoriteLayout.exgroupview.getExpandableListAdapter().getGroup(groupPosition);

      MusicItemDao musicDao = new MusicItemDao(this);

      switch (item.getItemId()) {
        case MENU_ADD_GROUP: // 添加分组
          favoriteLayout.Refresh(FavoriteLayout.ADD_GROUP);
          break;
        case MENU_CHI_PLAY_ONE: // 播放当前选择歌曲
          if (childPosition != -1) {
            MusicItem musicItem =
                (MusicItem)
                    favoriteLayout
                        .exgroupview
                        .getExpandableListAdapter()
                        .getChild(groupPosition, childPosition);
            Intent intent = new Intent(Constant.ACTION_FIND);
            musicname =
                Musicdata.getMusicbyid(context, String.valueOf(musicItem.getMusicId()))
                    .getMusicName();
            intent.putExtra("name", musicname);
            sendBroadcast(intent);
          }
          break;
        case MENU_CHI_PLAYALL: // 播放当前分组
          MyApplication.getInstance()
              .setMusics(
                  Musicdata.getmusicsByitem(musicDao.getMusicsByGroup(group.getId()), context));
          sendBroadcast(new Intent(Constant.ACTION_LISTCHANGED));
          break;
        case MENU_CHI_REMOVE: // 从分组中移除
          if (childPosition != -1) {
            // 获取musicitem对象
            MusicItem musicItems =
                (MusicItem)
                    favoriteLayout
                        .exgroupview
                        .getExpandableListAdapter()
                        .getChild(groupPosition, childPosition);
            // 获取该musicitem的id,删除
            musicDao.deleteItemById(musicItems.getId());
            // 更新界面
            favoriteLayout.Refresh(FavoriteLayout.REFRESH_GROUP);
          }
          break;
        case MENU_CLEAR_GROUP: // 清空分组
          musicDao.deleteItemByGroupid(group.getId());
          favoriteLayout.Refresh(FavoriteLayout.REFRESH_GROUP);
          break;
        case MENU_DELETE_GROUP: // 删除分组
          groupDao.deleteGroup(group.getId());
          favoriteLayout.Refresh(FavoriteLayout.REFRESH_GROUP);
          break;
        case MENU_UPDATE_GROUP: // 修改分组名称
          updatagroup(group.getId());
          break;
        case MENU_SETRING: // 铃声设置
          MusicItem musicItem1 =
              (MusicItem)
                  favoriteLayout
                      .exgroupview
                      .getExpandableListAdapter()
                      .getChild(groupPosition, childPosition);
          musicname =
              Musicdata.getMusicbyid(this.context, String.valueOf(musicItem1.getMusicId()))
                  .getMusicName();
          setMoreRing();
          break;
      }
    }
    return super.onContextItemSelected(item);
  }