Home > Web Front-end > H5 Tutorial > Li Yanhui HTML5 video data sharing

Li Yanhui HTML5 video data sharing

巴扎黑
Release: 2017-08-31 11:57:54
Original
3067 people have browsed it

Study the "Li Yanhui HTML5 Video Tutorial" video tutorial, which will introduce you to HTML5 in detail. HTML5 is the fifth major revision of Hypertext Markup Language (HTML), that is, the latest version; it adds some new features than the original standard. tags to achieve more functions, be more standardized, and be more suitable for mobile Internet.

Li Yanhui HTML5 video data sharing

Video playback address: //m.sbmmt.com/course/365.html

Difficulties of this course It lies in the new content in HTML5 and the usage of canvas:

Many drawing effects are achieved using canvas, so learning canvas well is the key to learning HTML5 well.

1. Introduction to canvas

1.1 What is canvas?

is an important element in HTML5. Similar to audio and video elements, it can run without any external plug-ins.

The Chinese translation of Canvas is "canvas". It provides powerful graphics. Processing functions (drawing, transformation, pixel processing...).

But it should be noted that the canvas element itself does not draw graphics, it is just equivalent to an empty canvas.

If developers need to draw graphics on the canvas, they must use JavaScript scripts to draw.

1.2 What can canvas do?

Drawing of basic graphics

Drawing of text

Deformation of graphics and synthesis of pictures

Processing of pictures and videos

Animation Implementation

Production of small games

1.3 Supported browsers

Most modern browsers support Canvas, such as Firefox, safari, chrome, and opera recently Versions and IE9 are supported.

IE8 and below do not support HTML5, but we can prompt users to update to the latest version

1.4 Basic concepts about canvas tags

In Defining the canvas element on an HTML page is no different from defining other ordinary elements. In addition to specifying common attributes such as id, style, class, hidden, etc., it can also set the width and height attributes.

Why do you have to say this specifically?

We will explain in detail in Chapter 2.2.

In addition, after we define the canvas element in the web page, it is just a blank canvas. If you want to draw on the canvas, you must go through the following steps.

Get the DOM object corresponding to the canvas element, which must be a canvas object

Call the getContext() method of the canvas object, which returns a canvasRenderingContext2D object, which can draw graphics.

Call the method of canvasRenderingContext2D object to draw.

Then let’s start our canvas practice and see how canvas can draw graphics.

2. Canvas actual combat

2.1 Check the current browser support for canvas

We also explained above that some of our browsers do not support canvas. What should we do at this time?

At this time we can write content directly between the canvas tags. The advantage of this is that when your browser does not support canvas, we can display the content between the tags, as follows.

<!DOCTYPE html>
<html>
 <head> 
  <meta charset="UTF-8" /> 
  <title>Document</title> 
  <style type="text/css">         
  html,body{     
          margin: 0px;   
       }         
    canvas{           
      background: #ccc;     
          }     
    </style> 
 </head> 
 <body> 
  <canvas>
    我们在设置 canvas 之前需要首先监测用户电脑是否支持 canvas 
  </canvas>  
 </body>
</html>
Copy after login

Now that the specific content has been created, can we see it now?

Although we have not given the width and height of the canvas, our canvas is actually visible on the page.

It should be noted that the width and height of the canvas default style are 300px * 150px.

Even if we do not set the specific width and height, it can still be displayed.

<!DOCTYPE html>
<html>
 <head> 
  <meta charset="UTF-8" /> 
  <title>Document</title> 
  <style type="text/css">   
  html,body{    
  margin: 0px;   
  }   
  canvas{    
  background: #ccc;   
  }  
  </style> 
 </head> 
 <body> 
  <canvas>
    我们在设置 canvas 之前需要首先监测用户电脑是否支持 canvas 
  </canvas>   
 </body>
</html>
Copy after login

The above is the detailed content of Li Yanhui HTML5 video data sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template