0

My goal is to record live audio stream then save it on my website programmaticaly.

I already do this job using android app that runs on android physical phone or android emulator .. the app reads stream bytes then save it in a file then upload it to my website .. can i do this job directly using cpanel php?

Can i get bytes from live audio stream and open new file using php then write this bytes inside it and finally save this file?

Thanks in advance and execuse me if this question wrong or not logic.

Code in Android

try {
  if (inputStream != null) {
    if ((output = inputStream.read(bytes, 0, bytes.length)) != -1) {
      buffer.write(bytes, 0, output);
    }
  }
} catch (IOException e) {
  e.printStackTrace();
}

Ahmed Gabr
  • 136
  • 3
  • 7
  • `it needs to run on a device...that's a bit vague..what kind of device? – ADyson Jan 01 '22 at 01:10
  • I run it as android app on physical phone or on android emulator – Ahmed Gabr Jan 01 '22 at 05:03
  • Php runs on a server normally, so it cannot directly record the audio from your phone. You'd need to record the audio and then upload it to the server. Php can then be used to save it to a suitable location on the server. It sounds like you're already doing that though – ADyson Jan 01 '22 at 07:14
  • I dont want to record from my phone .. its live audio stream from internet and i want to use php if applicable to save this stream by writing bytes in file – Ahmed Gabr Jan 01 '22 at 07:15
  • Please read my question after edit to know what i means – Ahmed Gabr Jan 01 '22 at 07:17
  • Your question doesn't mention where the stream comes from, so I assumed it was from the android device, since that was where you were recording it – ADyson Jan 01 '22 at 08:20
  • 1
    This is for video, but it's possible the same kind of approach might work, depending on the format of the stream you're talking about: https://stackoverflow.com/questions/32459509/php-recording-a-live-streaming-to-a-file (obviously you don't necessarily need to do the echo part) – ADyson Jan 01 '22 at 08:22
  • Thanks alot my friend .. this answer helped me so much. – Ahmed Gabr Jan 01 '22 at 10:41

0 Answers0