Skip to main content

learn advanced html Embedded Content: Video, Audio, and Canvas

The simplest embedded (foreign) content is an image, applied to a web page with the imgelement. In the olden days, object, along with various plugins and proprietary devil dust, was used to bash and smash video and audio into submission. Although not without its (compatibility) problems, there is now a much better method for using various types of media in web pages.

Video


<video src="kitties.mp4" controls></video>
Bam. There you go. Just like that. Simple.
This will embed a video, complete with controls, in browsers that support the HTML5 video tag and the video content type.




The controls attribute is optional but if you don’t want it - if you really want to take control away from the user - you can just slap in anautoplay attribute:

<video src="kitties.mp4" autoplay></video>
This will play the video on page load, won’t display any controls, and will most likely annoy the hell out of your visitors. Of course you could, if you were kind, put in both the controls andautoplay attributes.
Other basic attributes at your disposal includewidthheightloop, and muted.

<video src="kitties.mp4" width="300" height="200" loop muted autoplay controls></video>




Poster

You can specify a placeholder image, which will be displayed before the video is played, with theposter attribute.

<video src="kitties.mp4" poster="fluffy.jpg" controls></video>
The specified image will stretch or shrink to fit the dimensions of the video, regardless of the original size of the image.

Fall-back content

So, yes, there is an opening and closing tag. Whatever could go in between them? Why, fall-back content: content that is displayed if the browser doesn’t understand the video element. That could be a few words, a chunk of HTML, or a “really funny” and “highly original” Lolcats image.

<video src="kitties.mp4" controls>
    <img src="hahahaha.jpg" alt="Hilarious cat and caption saying 'soz'.">
</video>

Alternative content

As already noted, it’s not only compatibility with the tag we need to worry about, but also compatibility with the source video itself. Luckily, more than one video source file can be offered up with the source element along with indications of the requirements of the file in the value of the type attribute. The browser will then take the first one it’s happy with.

<video controls>
    <source src="kitties.mp4" type="video/mp4; codecs='avc1, mp4a'">
    <source src="kitties.webm" type="video/webm; codecs='vp8.0, vorbis'">
    <p>Browser no likey HTML 5.</p>
</video>
Here, a browser should figure out if it can handle the “video/mp4” MIME type and if it has the stated codec to decipher it. If it doesn’t, it should move on to the next and try again with the details set out in the second source element.

Audio

Applying audio is just like applying video. Using the audio tag, the structure is the same as usingvideo and the attributes srccontrols,autoplay and loop can all be used in the same way.

<audio src="meow_mix.mp3" controls>
    Your stupid browser doesn't support HTML 5 audio.
</audio>
Alternative content can also be defined in exactly the same way as with the video and sourcetags.




Canvas

A major addition to HTML5 is the canvaselement. It is designed to provide a canvas onto which JavaScript can be used to paint all manner of dynamic images such as graphs, animated sprites, or daft cat pictures.

<canvas id="wittykitty" width="800" height="450">
    <!-- Fall-back content here, just like with video and audio -->
</canvas>
That’s it. That’s the extent of the actual HTML, at least - the power is in the scripting.

Popular posts from this blog

Free tips to save yourself from phishing

Free tips to save yourself from phishing Phishing is a type of social building method utilized by programmers to assemble delicate data, for example, usernames, passwords and Visa points of interest by acting like a trustworty individual/association. Since most online clients are ignorant of the methods utilized as a part of completing a phishing assault, they regularly fall exploited people

Free internet browser download :internet explorer

Internet explorer full free downloads Internet explorer 11.0.11 full free download Internet explorer 10.0 full free download Internet explorer 9.0 full free download internet ex plorer lastest version download these are the lastest version of internet explorer...if you want anything else then let me by sending me comment i will try my best to give that...............

tricks to Hack an Email using Hardware Keylogger

tricks to Hack an Email using Hardware Keylogger Equipment Keyloggers are utilized for keystroke logging, a system for catching and recording machine client keystrokes. They connect to between a machine console and a machine and log all console action to an inward memory. They are intended to work with PS/2 consoles, and all the more as of late with USB consoles. An equipment keylogger seems just as a USB pendrive (thumb drive) or some other machine fringe so that the victimized people can never