Audio Management
The SDK mixes ad audio with other apps by default. Disable that if you manage the audio session yourself.
Audio Behavior by Placement Type
Media Placements
Device unmuted: Sound is OFF by default. Switched ON with a tap on the unmute button.
Device muted: Sound is OFF by default. Switched ON by switching the physical mute button (iOS) or increasing the Media Volume (Android).
Interstitial and Rewarded Placements
Device unmuted: Sound is ON by default. Switched OFF by a tap on the mute button.
Device muted: Sound is OFF by default. Switched ON by switching the physical mute button (iOS) or increasing the Media Volume (Android).
Audio Session Management
By default, the Teads inApp SDK handles the audio session by setting its category to ambient with mixWithOthers. This means that all the audio played by other applications will simply mix with the ad sound.
Custom Audio Session Management
If you choose to handle the audio session yourself, you can disable the SDK's audio session management.
Unified Placements (TeadsAdPlacementMedia / TeadsAdPlacementMediaNative)
Pass disableAudioSessionManagement: true in your config:
let config = TeadsAdPlacementMediaConfig(
pid: YOUR_PID,
disableAudioSessionManagement: true
)
let placement: TeadsAdPlacementMedia = Teads.createPlacement(
with: config,
delegate: self
)
Note:
TeadsAdPlacementMediaConfigis a SwiftstructandTeads.createPlacement<T>(with:delegate:)is generic — neither bridges to Objective-C, so no Objective-C sample can be produced for this snippet.
Then handle playback events through TeadsAdPlacementEventsDelegate:
- Swift
- Objective-C
func adPlacement(
_ placement: TeadsAdPlacementIdentifiable?,
didEmitEvent event: TeadsAdPlacementEventName,
data: [String: Any]?
) {
switch event {
case .startPlayAudio:
// Pause your app's audio
break
case .stopPlayAudio:
// Resume your app's audio
break
default:
break
}
}
- (void)adPlacement:(id<TeadsAdPlacementIdentifiable>)placement
didEmitEvent:(TeadsAdPlacementEventName)event
data:(NSDictionary<NSString *, id> *)data {
switch (event) {
case TeadsAdPlacementEventNameStartPlayAudio:
// Pause your app's audio
break;
case TeadsAdPlacementEventNameStopPlayAudio:
// Resume your app's audio
break;
default:
break;
}
}
Legacy Placements (inRead / inFeed Native)
Call disableTeadsAudioSessionManagement in your placement settings:
- Swift
- Objective-C
let settings = TeadsAdPlacementSettings { settings in
settings.disableTeadsAudioSessionManagement()
}
let placement = Teads.createInReadPlacement(
pid: YOUR_PID,
settings: settings,
delegate: self
)
TeadsAdPlacementSettings *settings = [[TeadsAdPlacementSettings alloc] initWithBuild:^(TeadsAdPlacementSettings *settings) {
[settings disableTeadsAudioSessionManagement];
}];
id<TeadsInReadAdPlacement> placement = [Teads
createInReadPlacementWithPid:YOUR_PID
settings:settings
delegate:self];
Then register for playbackDelegate when receiving the ad:
- Swift
- Objective-C
func didReceiveAd(ad: TeadsInReadAd, adRatio: TeadsAdRatio) {
ad.playbackDelegate = self
}
- (void)didReceiveAdWithAd:(TeadsInReadAd *)ad adRatio:(TeadsAdRatio *)adRatio {
ad.playbackDelegate = self;
}
And implement TeadsPlaybackDelegate:
- Swift
- Objective-C
func adStartPlayingAudio(_ ad: TeadsAd) {
// Pause your app's audio
}
func adStopPlayingAudio(_ ad: TeadsAd) {
// Resume your app's audio
}
- (void)adStartPlayingAudio:(TeadsAd *)ad {
// Pause your app's audio
}
- (void)adStopPlayingAudio:(TeadsAd *)ad {
// Resume your app's audio
}
Available Playback Events
| Event | Description |
|---|---|
.startPlayAudio | Ad started playing audio |
.stopPlayAudio | Ad stopped playing audio |
.play | Ad video started or resumed |
.pause | Ad video paused |
.complete | Ad video completed |
A non-mixable session stops other apps (for example Spotify) when an ad starts, even a silent ad. Add mixWithOthers (for example on .playback) so ad audio mixes with other apps.