Play local video in uiwebview

Download the local html file in the 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 is displayed, the contents 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> 

therefore 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 web browser is black. The video does not load. I uploaded my html file and my .m4v video to my web server to check if it is encoded correctly, but everything works fine, viewing the html file using my ipad.

are some ideas wrong?

+4
source share
4 answers

Oh my God

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

where controls is the magic word.

: X

+8
source

Maybe I'm wrong (or stupid), but have you tried file:///banane.m4v (add an extra "/" for root)

0
source

For everyone who experiences a crossed out game symbol, When you drag and drop your video files (mp4 works, just make sure the codec is in order - the easiest way to export your iPhone using QuickTime) is a dialog box. Make sure you mark your application in the "add to targets" section.

Or, if you have already copied your video into the project, if you click it in the Xcode file browser, you will have an option on the right side for choosing targets.

0
source

You need to set the allowsInlineMediaPlayback property in the UIWebView :

 [webView setAllowsInlineMediaPlayback:YES]; 
0
source

Source: https://habr.com/ru/post/1337587/


All Articles