UIWebview dos does not play mp4 video

I tried to play .mp4 video from a website (using HTML5 Video Tag) using UIWebView. The iPhone / iPad and simulator show only a black frame with the play button pressed. If I just named this website in the Safari Mac version, it can be played. What's the matter?

This is not a local file. The html looks like this:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" href="../css/shared-culture.css" /> </head> <body> <section class="base"> <hgroup> <h1>creative commons</h1> <h2>a shared culture</h2> </hgroup> <p>To celebrate our 2008 fundraising campaign, Creative Commons has released "A Shared Culture," a short video by renowned filmmaker <a href="http://en.wikipedia.org/wiki/Jesse_Dylan">Jesse Dylan</a>. Known for helming a variety of films, music videos, and the Emmy Award-winning <a href="http://my.barackobama.com/page/invite/yeswecanvideo">"Yes We Can"</a> Barack Obama campaign video collaboration with rapper will.i.am, Dylan created "A Shared Culture" to help spread the word about the Creative Commons mission. </p> <!-- height="240" width="360" --> <video id="video1" controls="controls"> <source src="../video/shared-culture.mp4" type="video/mp4"/> <source src="../video/shared-culture.webm" type="video/webm"/> <div class="errmsg"> <p>Your Reading System does not support (this) video.</p> <pre><code> &lt;video id="video1" controls="controls"&gt; &lt;source src="../video/shared-culture.mp4" type="video/mp4"/&gt; &lt;source src="../video/shared-culture.webm" type="video/webm"/&gt; &lt;/video&gt; </code></pre> </div> </video> <p>In the video, some of the leading thinkers behind Creative Commons describe how the organization is helping "save the world from failed sharing" through free tools that enable creators to easily make their work available to the public for legal sharing and remix. Dylan puts the Creative Commons system into action by punctuating the interview footage with dozens of photos that have been offered to the public for use under CC licenses. Similarly, he used two CC-licensed instrumental pieces by Nine Inch Nails as the video's soundtrack music. These tracks, "17 Ghosts II" and "21 Ghosts III," come from the Nine Inch Nails album Ghosts I-IV, which was released earlier this year under a Creative Commons BY-NC-SA license. (See <a href="http://creativecommons.org/videos/a-shared-culture">attribution</a>.) </p> </section> </body> </html> 
+8
ios screen video uiwebview frame
source share
6 answers

It may not be suitable for iPhone.

Drag and drop the mp4 file into iMovie, and then click Share β†’ Export Movie and select one of the iPhone compatible formats.

+9
source share

One way that videos may not play in UIWebView is that the web server that hosts the video does not support byte ranges. UIWebView does not load the entire .mp4 file at the same time; instead, it transfers the video requesting parts of the file. Most servers these days support byte ranges, but if yours is not, or if you disabled it for some reason, you won’t be able to display the video on your iOS device.

+4
source share

Sounds like a problem with the codec. You can see which codecs are used by the file, if you open it in VLC on your computer, go to "Window"> "Library Information" - "Codec Information". The answer here is related to Apple docs, where you will find supported video and audio codecs:

https://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.html

https://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html

+2
source share

This may be a problem with the relative type ../ that you are using. Try using the full absolute path - starting with http:// .

+1
source share

I also have this problem, I have 2 .mp4 , but it is possible to use, but one is not, I am trying to format a file like .mp4 to .mp4 for iPad, and it works, I think you should try.

0
source share

Playing mp4 video for iPhone programming is not very difficult. We just need to do another drag and drop.

please take a new project with one view. then in the file ViewController.m just copy and paste this code

  #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize webView; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. CGRect screenRect = [[UIScreen mainScreen] bounds]; CGFloat screenWidth = screenRect.size.width; CGFloat screenHeight = screenRect.size.height; webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0,screenWidth,screenHeight)]; NSURL *url = [[NSBundle mainBundle] URLForResource:@"testingHTML" withExtension:@"html"]; NSLog(@"%@",url); [self.webView loadRequest:[NSURLRequest requestWithURL:url]]; // NSURL *nsurl=[NSURL URLWithString:url]; //NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl]; // [webView loadRequest:nsrequest]; [self.view addSubview:webView]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end 

Then create an HTML file called testingHTML.html

and copy and paste the following code into the HTML file

 <!DOCTYPE html> <html> <head></head> <body> <center> <video width="250" height="304" controls preload> <source src="video1.mp4" type="video/mp4"> </video> </center> <p>Thanks to Md Kamrul Hasan .....mdkamrul.hasan@marquette.edu</p> </body> </html> 

Drag a video like MP4 into two places:

First: drag the video from the hard drive to the project tab [X tab Left tab] Second: on the left side of Xcode, again DRAG SAME VIDEO FILE in Project ---> Build Phases ---> Copy Bundle Resources

Typically, Copy bundle resources contain project files, but sometimes they do not contain video files.

NOW WORK a project and ENJOY the video ...... !!

Luck

-one
source share

All Articles