choise
choise

Reputation: 25244

playing a local video in a uiwebview

i load a local html file into an ipad application:

NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
NSString *path = [[NSBundle mainBundle] pathForResource:@"lieferant1" ofType:@"html"];
NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:content baseURL:baseURL];

the webpage gets displayed, content of my html file:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
<p>
    <video>
        <source src="banane.m4v">
    </video>
</p>

so, banane.m4v is in my root, just in some groups, but not in real directories. enter image description here

but the video section in my webview keeps black. no video gets loaded. i uploaded my html file and my .m4v video to my webserver to check if its not encoded properly, but everything works fine, surfing the html file with my ipad.

some ideas whats wrong?

Upvotes: 5

Views: 4495

Answers (4)

Mark Ingram
Mark Ingram

Reputation: 73585

You need to set the allowsInlineMediaPlayback property on the UIWebView:

[webView setAllowsInlineMediaPlayback:YES];

Upvotes: 0

Kevin Grabher
Kevin Grabher

Reputation: 399

For everyone that experiences a crossed out play symbol, When you drag your movie-files (mp4's work as well, just make sure the codec is okay - easiest way is to export for iPhone with QuickTime) a dialog appears. Make sure you tick your app under "add to targets".

Or if you already copied your video into the project, if you click it in Xcode's file browser, you'll have an option on the right-hand side to select targets.

Upvotes: 0

ifreeman
ifreeman

Reputation: 31

I may be wrong (or silly) but, did you try file:///banane.m4v (Add the extra '/' for root)

Upvotes: 0

choise
choise

Reputation: 25244

oh my god

<video controls>
    <source src="banane.m4v">
</video>

where controls is the magic word.

:X

Upvotes: 9

Related Questions