是否可以在输入流中复制字节时播放部分mp3音频文件

时间:2015-07-01 17:49:41

标签: android inputstream android-mediaplayer

使用蓝牙连接两个设备。是否可以播放正在收到的mp3歌曲。     while(fileSize> = TConstants.CHUNK_SIZE)                 {                     int readLen = 0;                     readLen = inputStream.read(buf,0,TConstants.CHUNK_SIZE);                     if(readLen< 0)                         抛出新的TException(TException.EXCEPTION_READ_FILE);

                out.write(buf, 0, readLen);
                len += readLen;
                fileSize -= readLen;
                if (listener!=null && ((len / TConstants.CHUNK_SIZE) != prev))
                {
                    prev = len / TConstants.CHUNK_SIZE;
                    Log.d(TAG, "Chunk read " + prev + "");
                    receiverConsignment.setReadFileSize(len);
                    listener.onChunkRead(receiverConsignment);
                    // showSpinnerProgress(fileTransferModel);
                }
            }

            while (fileSize > 0)
            {
                buf = new byte[(int) fileSize];
                len = inputStream.read(buf);
                if (len < 0)
                {
                    throw new TException(TException.EXCEPTION_READ_FILE);
                }
                fileSize -= len;
                out.write(buf, 0, len);
            }
            out.close();
        }
        catch (IOException e)
        {
            Log.e(TAG, "Exception in copyFile: ", e);
            out.close();
            throw new TException(e, TException.EXCEPTION_READ_FILE);
        }

0 个答案:

没有答案