Audio In Html Of Ios Webview Control Doesnot Work
I have included a audio tag in html and i am loading the html inside the UIWebview control. The audio plays when i click on the play button. But when i put the phone in silent mode
Solution 1:
Please add below code:-
NSError *setCategoryErr = nil;
NSError *activationErr = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&setCategoryErr];
[[AVAudioSession sharedInstance] setActive:YES error:&activationErr];
IF you want to run audio even if app is in background mode than use below code in application:didFinishLaunchingWithOpitons:
[[AVAudioSession sharedInstance] setDelegate:self];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
applicationDidEnterBackground:
[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
Hope, now this will help you.
Post a Comment for "Audio In Html Of Ios Webview Control Doesnot Work"