0

when i load local html file into my iOS app every thing work fine but in the html file there is an animation (images+sounds) the sounds file founded under the folder reference "edge in folder named media " the problem is the animated images work fine but without any sound can any one advice me ?

and there is my code

    localContent = [[UIWebView alloc] initWithFrame:CGRectMake(0, 60, 1024, 768)];
           NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"inDirectory:@"Edge"];

            NSURL *url = [NSURL fileURLWithPath:path];
            NSURLRequest *request = [NSURLRequest requestWithURL:url];

            [localContent loadRequest:request];

            [self.view addSubview: localContent];
cat
  • 25
  • 1
  • 2
  • 10
  • see this thread http://stackoverflow.com/q/8044447/1403732 and also post part of your html related to sound – sage444 Jul 24 '14 at 11:04

2 Answers2

0

You have to write some java script code when your webview finish loading delegate is called..

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    NSURLRequest* request = [webView request];
    NSString *page = [request.URL lastPathComponent];
    if ([page isEqualToString:@"index.html"]){
        NSString *js = @"startVideo();";
        [myWebMain stringByEvaluatingJavaScriptFromString:js];
    }
}
And here's my javascript function:

<script>
function startVideo(){
var pElement3 = document.getElementById('myVideo');
pElement3.play();
}
</script>
And here's the html in case you're new to html video

<video id="myVideo" poster="index_poster.png" width="1024" height="768" xcontrols     autoplay="autoplay">
<source src="flow.m4v" type="video/mp4"/>
browser not supports the video
</video>
Mohit
  • 516
  • 7
  • 24
0

MyWebView.allowsInlineMediaPlayback = YES;

MyWebView.mediaPlaybackRequiresUserAction = NO;

cat
  • 25
  • 1
  • 2
  • 10