Your Cart
Loading

B4X Example Audio (B4A+B4I+B4J)

On Sale
$0.00
Free Download
Added to cart

Explanation of the Solution

  1. Audio Session Configuration on iOS:
  • On iOS, audio playback depends on the correct configuration of the audio session (AVAudioSession). By default, iOS may block or mute sounds if the audio session is not explicitly configured.
  • The AVAudioSessionCategoryPlayback category allows audio to play even when the device is in silent mode (mute).
  1. Adding Code to Application_Start:
  • The setAudioSession method is called at the start of the application to configure the audio session. This ensures that the app is ready to play MP3 sounds as soon as needed.
  1. Using Native Code (Objective-C):
  • Since B4i does not have a direct API to configure the audio session, you used native Objective-C code to access the AVAudioSession class and set the audio category.
  • The Objective-C snippet (#If OBJC) configures the audio session and handles potential errors, logging them to the console for debugging.
  1. Integration with MediaPlayer:
  • After setting up the audio session, the MediaPlayer can be used normally to play MP3 sound files.


You will get a ZIP (792KB) file