Reputation: 7218
I have an iOS app on the app store with 2 instructional videos. The videos play fine on all devices except on iPad, in which case there is no audio. The video plays fine on iPhone (via WebView inside the native app), PC, Mac, and even iPad Safari -- but not inside the iPad app itself, which displays web content through an embedded native WebView.
Here is one of the videos: http://www.mapsandtreasures.com/HowToPlay_iOS.php
Here is the HTML tag for the video:
<video src="videos/Play.mov" poster="videos/Play.png" controls="true" width="800" height="472"></video>
The direct URL to the mov file is this: http://www.mapsandtreasures.com/videos/Play.mov
Any reason why the video (including audio) would play with no problems on such a wide variety of devices, but not in an iPad app via WebView? (Especially given that the same app plays the videos fine on an iPhone.)
Upvotes: 2
Views: 778
Reputation: 1169
Ok, I found the answer. Here is how you get it working.
//Enable Audio
NSError *error;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
if (error) {
NSLog(@"Error in setting category = %@", error);
//handle error here.
}
[[AVAudioSession sharedInstance] setActive:YES error:&error];
if (error) {
NSLog(@"Error in activating session = %@", error);
//handle error here.
}
Happy coding :)
Upvotes: 1