好像你的URL和connection之间没啥关系啊

解决方案 »

  1.   

    试试这个:    /* 判断传入的地址是否为URL */
        if (!URLUtil.isNetworkUrl(strPath))
        {
          mMediaPlayer01.setDataSource(strPath);
        }
        else
        {
          if(bIsReleased == false)
          {
            /* 创建URL对象 */
            URL myURL = new URL(strPath);  
            URLConnection conn = myURL.openConnection();  
            conn.connect();        
            /* 取得URLConnection的InputStream */
            InputStream is = conn.getInputStream();  
            if (is == null)
            {
              throw new RuntimeException("stream is null");
            }   
            /* 创建新的临时文件 */
            File myTempFile = File.createTempFile("temp", "."+getFileExtension(strPath));
            currentTempFilePath = myTempFile.getAbsolutePath();   
            FileOutputStream fos = new FileOutputStream(myTempFile);
            byte buf[] = new byte[128];  
            do
            { 
              int numread = is.read(buf);
              if (numread <= 0)
              {
                break;
              }
              fos.write(buf, 0, numread);
            }while (true);
        }
      

  2.   

    LZ的文件路径不对吧
    File musicFile = new File("/sdcard/");这个只是一个目录吧 
      

  3.   

    没有创建文件,/sdcard/mp3.mp3.还有byte[] bt = new byte[is.available()];这种做法不是很安全,这可能会导致文件读取不完整。最好的做法是每次读取1K,byte[] bt = new byte[1024]