MediaRecorder issue on Android Lollipop

前端 未结 2 1677
执念已碎
执念已碎 2020-12-01 06:30

I\'m testing libstreaming on new Android Lollipop, and this code that worked on previous release, seems to launch exception.

    try {
              


        
2条回答
  •  情深已故
    2020-12-01 07:22

    at Android 6.0 I resolve this problem with the code

    new Thread(new Runnable() {
      @Override public void run() {
        FileInputStream inputStream = null;
        try {
          inputStream = new FileInputStream(path);
        } catch (FileNotFoundException e) {
          e.printStackTrace();
        }
        while (true) {
          byte[] buffer = new byte[0];
          try {
            buffer = new byte[inputStream.available()];
          } catch (IOException e) {
            e.printStackTrace();
          }
          try {
            inputStream.read(buffer);
          } catch (IOException e) {
            e.printStackTrace();
          }
          try {
            mSender.getOutputStream().write(buffer);
            mSender.getOutputStream().flush();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
    }).start();
    

    I use a file as buffer and write bytes at another thread.the MediaRecorder output to the file.

提交回复
热议问题