Html5 video not playing in ipad simulator?

I created a universal xcode project, I'm trying to load an HTML5 page in a UIWebView

the problem is that I don’t see any movie playback control, and I get a blank screen on the video

place in ipad and iphone simulator,

my .html file

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <!-- Change this if you want to allow scaling --> <meta name="viewport" content="width=default-width; user-scalable=no" />  <meta http-equiv="Content-type" content="text/html; charset=utf-8">  <title>Web App Demo</title>  </head> <body> <h1>Video Test</h1> <p>This is a video test.</p> <video width="320" height="240" controls= "controls"> <source src="video.ogv" type="video/ogg" /> <source src="video.mp4" type="video/mp4"/> browser not supports the video </video> </br> <br/> <h1>This is Audio </h1> <b>Testing Audio </b> <audio controls="controls"> <source src="audio.ogg" type="audio/ogg" /> <source src="audio.mp3" type="audio/mpeg"/> browser not supporting audio </audio> </body> </html> 

Any help why he is not playing in the simulator.

Thanks in advance.

+4
source share
4 answers

It looks like this could be a problem. You are using relative paths for the video, so they must be in the place that HTML expects them to find them. You need to either use the absolute paths for the files in your bundle, or make sure that the base href is defined to point to the appropriate folder containing these images, either explicitly in HTML, or by specifying the correct baseref in loadHTMLString: baseURL: call.

One way to quickly check if this is a problem is to put .png next to the video files and link to it in HTML. If .png is not displayed, this is not a problem with the video, but the problem of finding assets.

0
source

I saw this before when there are problems with URLs - for example, with capitalization ... The simulator is more relaxed than the device ... Check the exact file names ...

+1
source

I read that the mp4 file must be placed in front of the ogv file for the iPad in order to play it.

0
source

I play the m4v file in my uiwebview, but the translucent play button does not appear in my simulator. It really works on the device itself, though ....

  <video id="VideoDiv" preload src="http://www.movietime.com/movie.m4v" controls width="480px" height="270" poster="poster.png"></video> 
0
source

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


All Articles