ryanheise / audio_service

Flutter plugin to play audio in the background while the screen is off.
795 stars 475 forks source link

Is it possible to change the AudioManager's stream type from STREAM_MUSIC to something else? #1080

Open ryotasakurada opened 2 months ago

ryotasakurada commented 2 months ago

Feature proposal

The audio_service feature is usually used in conjunction with music, but we plan to use it in conjunction with the calling feature. At that time, the stream type of AudioManager is fixed to STREAM_MUSIC, and the volume button cannot be used as the call volume.

If I fix change(insert) codes at
https://github.com/ryanheise/audio_service/blob/e3abd9b7ab31c49b8abc238d508ed6fe0afd4507/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java#L587 https://github.com/ryanheise/audio_service/blob/e3abd9b7ab31c49b8abc238d508ed6fe0afd4507/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java#L323

mediaSession.setPlaybackToLocal(AudioManager.STREAM_VOICE_CALL);

Then it was possible to solve the problem. But it would be very nice to have it as a function.

Motivating use case(s)

When combining audio_service with uses other than music playback.

ryanheise commented 2 months ago

I would be open to this, but can you propose a surface API?