iOS Question no sound on web page

Erel

Administrator
Staff member
Licensed User
You need to set the audio session before you load the layout:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Dim jo As NativeObject = Me
   jo.RunMethod("setAudioSession", Null)
   Page1.Initialize("Page1")
   Page1.RootPanel.LoadLayout("1")
   NavControl.ShowPage(Page1)
End Sub


#If OBJC
#import <AVFoundation/AVFoundation.h>
- (void) setAudioSession {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
BOOL ok;
NSError *setCategoryError = nil;
ok = [audioSession setCategory:AVAudioSessionCategoryPlayback
  error:&setCategoryError];
if (!ok) {
  NSLog(@"%s setCategoryError=%@", __PRETTY_FUNCTION__, setCategoryError);
}
}
#end if
I tried it with your website and it didn't seem to work. Maybe they are not including the music in the device version.
It did work with a different site I tried.
 

John Woodsmall

Active Member
Licensed User
thanks for this, but:
how do I put the #if OBJC into the app program that I have now?
I tried to insert it at the top or the bottom and it would not compile?
 

John Woodsmall

Active Member
Licensed User
I place the above object C code below the last line of my app:
and I get the following error.
End Sub
expected identifier or '('
Out: Build settings from command line:
ARCHS = armv7 arm64
CODE_SIGN_IDENTITY = iPhone
CONFIGURATION_BUILD_DIR = /Users/user1/Downloads/macserver-aa-5/UploadedProjects/b4i_default/Payload
OTHER_CODE_SIGN_FLAGS = --keychain b4i_default
PRODUCT_NAME = AstroMatch_Store
PROVISIONING_PROFILE = 571eeb78-44ce-4e92-8315-4aa50d95eb7e
=== BUILD TARGET B4iProject OF PROJECT B4iProject WITH CONFIGURATION Release ===
Check dependencies
...alot more errors below this.
 
Top