Video- Easily Play a Video in Your Web Page

Written by @m_k_amin 7 June 2013

Video is a great feature for websites and make more robust connection with users. HTML5 prepared a tool for playing different video formats. You may be annoyed from playing video before, because of finding a suitable player, but now it is easy, reliable and fast by HTML5 video element. In the following code you can see how we can play a video just by few lines of code. The HTML5 video element supports many events and attributes but they were not included in this example because of simplicity. Although some browsers may not support specific video types, by defining multiple sources, if one fails, it goes automatically to the next format; so the video element becomes browser friendly.

Code Snippet:

                                                
                                                <!-- this script is provided by www.html5freecode.com coded by: Kerixa Inc. -->
<!-- This Script is from www.html5freecode.com, Coded by: Kerixa Inc-->
<video width="320" height="220" controls autoplay onloadeddata="ply()" id="vid">
	<source src="http://www.html5freecode.com/files/html5-video-element-sample.ogg" type="video/ogg">
	<source src="http://www.html5freecode.com/files/html5-video-element-sample.mp4" type="video/mp4">
</video>
<div style="text-align: left"><br><font face="Tahoma"><br><a target="_blank" href="http://www.html5freecode.com"><span style="font-size: 8pt; text-decoration: none">HTML5 Free Code</span></a></font></div>
<script>
function ply(){
	var vid= document.getElementById('vid')
	vid.play()	
}
</script><a target='_blank' href='www.html5freecode.com' style='font-size: 8pt; text-decoration: none'>Html5 Free Codes</a>                                                
                                            

Example:


About @m_k_amin

This user is pending a biography.

M

Comments


Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

TRENDING POST
1
2
3
4
5
VISITORS
Online Users: 12
Recent Members: FOTPU
advertisement 2