August 28, 2009
HTML 5 Video and Audio in UIWebView and WebView
I have been playing with the video and audio tags in the UIWebView on the iPhone and WebView on the Mac. I tried them in the QT WebView as well on linux. I am pleased to announce that they work great! I have tried it with mp3, mp4, and wmv. All worked on all three platforms.
It looks like this is a good way to display videos for your users to play in your hybrid applications.
Let’s say you have a video called someCrazyMovie.mp4 that you want to display to your users. On the iPhone or the Mac put it in the Resources group of your Xcode project that uses a UIWebView. Point the UIWebView to a local html file, also in the resources file.
In this html file put the following code.
<video src=”someCrazyMovie.mp4>A movie description as an alt</video>
When you run your application you will see the first frame of the video used as a representational image. You can play it by clicking it. On the iPhone and iPod touch the movie player launches to play the movie.
The tag lets you size it, display or not display the video controls, etc.
The audio tag is used much the same way.
I’ll include an example for both the iPhone and the Mac in the 1.5.0 release of QuickConnectiPhone 1.5.0