我无法通过单击列表项来播放暂停和从SD卡播放相同的内容

时间:2015-10-15 12:47:15

标签: media-player

我的代码如下。

  //for clicking the item in the list view
  protected void onListItemClick(ListView l, View v, int position, long id)
  {
      Cursor cursor = adapter.getCursor();
      cursor.moveToPosition(position);
      String _id = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media._ID));
      Uri playableUri= Uri.withAppendedPath(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,_id );
      MainActivity.RingStart(getBaseContext(), playableUri, position);
  }

  //there is another class in which has a method with same name and parameter(RingStart)
  public static void RingStart(Context contxt, Uri fileuri,int pos)
  {
            if(mp!=null  && mp.isPlaying())
              {
                    mp.stop();
                    mp.reset();
              }

              mp =MediaPlayer.create(contxt, fileuri);
              if(oldpos !=pos)
              mp.start();
              oldpos = pos; 
    }

0 个答案:

没有答案
相关问题