apache / apache/cordova-plugin-media

iOS: Mixing audio with other apps

Open
#306 0 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
391
Forks
762
PR merge metrics
No merged PRs in 30d

Description

# Feature Request
Make this plugin able to mix with background audio from other apps. Support the audio ducking feature as well.

## Motivation Behind Feature
The plugin currently supports only the AVAudioSessionCategories `AVAudioSessionCategoryPlayback` & `AVAudioSessionAmbientSolo`.

This makes it impossible to mix the apps audio with e.g. music coming from spotify in the background.

## Feature Description
The `startPlayingAudio()` should accept an optional parameters `mixWithBackgroundAudio` and `duckBackgroundAudio` for this along the lines of the already accepted `playAudioWhenScreenIsLocked`.

When the parameters to mix with other audio is set to true the AVAudioSessionCategory should be set to

`[self.avSession setCategory:AVAudioSessionCategoryAmbient withOptions:(AVAudioSessionCategoryOptionMixWithOthers, AVAudioSessionCategoryOptionDuckOthers) error:&err];`

(and the audio ducking as well)

## Alternatives or Workarounds
change the AVAudioSessionCategory by hand and install local version of this plugin

Contributor guide

Open the contributing guide

Research direction

Start by locating the iOS implementation of startPlayingAudio() and its AVAudioSession setup. Read how playAudioWhenScreenIsLocked is handled, then trace the existing category and option choices. Done means the optional mixWithBackgroundAudio and duckBackgroundAudio parameters produce the requested background mixing and ducking behavior without changing existing defaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, objective-c
Domain
audio-video-rtc, mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.