Vote count:
0
Hi I've read all the questions regarding playing audio in the background and the apple documentation found here http://ift.tt/1op3SIL however none of these help me as I am trying to use a UIWebview video. I am able to play the audio when the audio is in the background, but when I click the lock button on the iphone or the menu button the video pauses, I then have to press play again from the iphones media player.
Here is the code for the Uiwebview:
-(void) setup {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
BOOL ok;
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setActive:YES
error:nil];
ok = [audioSession setCategory:AVAudioSessionCategoryPlayback
error:&setCategoryError];
if (!ok) {
NSLog(@"%s setCategoryError=%@", __PRETTY_FUNCTION__, setCategoryError);
}
self.webView.delegate=self;
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 150)];
[webView setMediaPlaybackRequiresUserAction:NO];
NSURL *myURL = [NSURL URLWithString: self.url];
NSURLRequest *request = [NSURLRequest requestWithURL:myURL];
self.webView.allowsInlineMediaPlayback=YES;
self.webView.mediaPlaybackAllowsAirPlay = YES;
[self.view addSubview:_webView];
[self.webView loadRequest:request];
asked 29 secs ago
Aucun commentaire:
Enregistrer un commentaire