0

I am using a simple icecast streaming app.

https://github.com/fatihsokmen/android-icecast-broadcast

I want it to continue streaming even when applications such as whatapp are active.

I do not want to capture the conversation just continue streaming from the one device.

any idea if this is possible?

noob
  • 3
  • 1

1 Answers1

0

You Can Try Follwoing way ,

  1. First Check whatsapp is Open or not

  2. Create service to record Audio

    • Here is example how to record audio using Service.

    public class AudioRecordService extends Service {

        private static final String TAG = AudioRecordService.class.getSimpleName();
    
    
        MediaRecorder mediaRecorder;
    
        private ShardPref mPref;
    
    
        public void onCreate() {
            Log.e(TAG, "onCreate: ");
            mPref = new ShardPref(this);
            super.onCreate();
    
        }
    
        @Override
        public int onStartCommand(Intent intent, int flags, int startId) {
            Log.e(TAG, "onStartCommand: ");
            MediaRecorderReady();
            return super.onStartCommand(intent, flags, startId);
        }
    
        public void onDestroy() {
            Log.e(TAG, "onDestroy: ");
            if (mediaRecorder != null) {
                mediaRecorder.stop();
            }
    
            super.onDestroy();
    
        }
    
    
        @Override
        public IBinder onBind(Intent intent) {
            return null;
        }
    
        private String getFilename() {
    
    
            File root = new File(Environment.getExternalStorageDirectory() + File.separator + FolderUtils.AUDIO_FOLDER_NAME + File.separator);
            if (!root.exists()) {
                root.mkdirs();
            }
            String filename = Utils.getAudioName(Constant.AUDIO_PATH);
            mPref.setCurrentAudioFileName(filename);
    
            return (root.getAbsolutePath() + "/" + filename);
    
    
        }
    
        public void MediaRecorderReady() {
            mediaRecorder = new MediaRecorder();
            mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
            mediaRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
            mediaRecorder.setOutputFile(getFilename());
            Log.e(TAG, "Media Recording Audio");
            try {
                mediaRecorder.prepare();
                mediaRecorder.start();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    
    
    }
    

Note : Please handle require permission

Community
  • 1
  • 1
Sachin
  • 1,307
  • 13
  • 23