Skip to content

Commit 4fc0e41

Browse files
author
Robin Smith
committed
Play iPhone audio through default speaker when no devices connected
When no devices are connected, play audio through the default audio playback speakers (for iPhone 6, 7, 8 these are located at the bottom of the handset) rather than through the earpiece speaker, which is designed for taking calls and is much quieter.
1 parent 86f15de commit 4fc0e41

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ios/RmxAudioPlayer.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ - (void) pluginInitialize
4545
_isReplacingItems = NO;
4646
_isWaitingToStartPlayback = NO;
4747
self.rate = 1.0f;
48-
self.volume = 1f;
48+
self.volume = 1.0f;
4949
self.loop = false;
5050

5151
[self activateAudioSession];
@@ -1284,6 +1284,9 @@ - (void) activateAudioSession
12841284
options |= AVAudioSessionCategoryOptionAllowBluetoothA2DP;
12851285
}
12861286

1287+
// If no devices are connected, play audio through the default speaker (rather than the earpiece)
1288+
options |= AVAudioSessionCategoryOptionDefaultToSpeaker;
1289+
12871290
[avSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:options error:&categoryError];
12881291
if (categoryError) {
12891292
NSLog(@"Error setting category! %@", [categoryError description]);

0 commit comments

Comments
 (0)