


Sharing of plans to enhance browser compatibility of the video tag in HTML5
When using HTML5, you should consider browser compatibility issues including desktop and mobile. Especially in terms of video, browser support for decoding will be different, so let’s share an enhancement to the browser compatibility of the HTML5 video tag. Solution sharing, friends who need it can refer to
In the past, flash was the best way to solve videos on web pages. Up to now, it is still mainstream, such as those video websites like Youku and online music like Xiami. The website still uses flash to provide playback services. But this situation will change with the development of HTML5. As far as video is concerned, HTML5 adds video to implement the function of playing videos online.
Using HTML5 video, you can easily use JavaScript to control the video content, etc. The function is very powerful, and the code is relatively small to speed up the loading speed. In addition, cross-platform is relatively good, especially some tablets, mobile phones, etc. For example, Apple's products do not support flash and only support the video function in HTML5.
But the compatibility issue of HTML5 is a flaw. We can use video to play videos on web pages, but visitors using early browsers may not be able to watch this video normally. In addition, due to the historical origin of video encoders, various browsers support different video formats. To deal with these problems and want to use the HTML5 video function in web pages, you can follow the following three steps.
Step one: Prepare multi-format video files in advance
Due to the copyright issue of the encoder, different browsers have different compatibility with video formats. Currently, no video format is compatible with all browsers, and the only solution is to convert the video into multiple formats.
First, prepare a video in mp4 format, which can be used on Apple devices; secondly, prepare a video in ogv format, which can be used in Firefox; finally, prepare a video in webm format, which can be used on Google Chrome, etc. Webm was proposed by Google. It is open source, free, and is likely to become a video format compatible with all browsers.
The trouble with preparing a multi-format browser is converting the formats. Domestic video conversion tools have relatively few functions, the conversion format may not be as good as the last two above, and the quality varies, and registration is often required before use. Recommend a foreign tool, Online converter, a free online video conversion tool. You don't even need to install software, just select the corresponding target format, then upload the video, configure the parameters and you can convert it. If you don’t have the right tools, you can give it a try.
Step 2: Write the corresponding HTML5 video code
The video in HTML5 is actually a simple tag that contains some video-related information. I will directly give the specific code below, and then briefly explain it: The
<video width=”800” height=”374”> <source src=”my_video.mp4” type=”video/mp4” /> <source src=”my_video.ogv” type=”video/ogg” /> <source src=”my_video.webm” type=”video/webm” /> 你浏览器不支持 video 功能,点击这里下载视频: <a href=”video.webm”>下载视频</a>. </video>
video tag indicates that this is a video, and the width and height attributes respectively indicate the width and height (unit pixels) of the video content. The video tag can contain the source tag, which is used to indicate the referenced video and the format and type of the video. In order to ensure downward compatibility, we also added a prompt in the video tag. This sentence will not be displayed in browsers that support the video tag. If it is not supported, it will be displayed. Here, a video download address is also added. If the browser does not support it, users can choose to download it and watch it.
One thing to note in particular is that your host must be able to handle these video requests correctly. Make sure your host sends the correct MIME type in the Content-Type header when requested for these videos. If you are not sure, you can consult the hosting service provider or add it yourself. If the host supports .htaccess, you can add the following statement to the .htaccess file:
AddType video/ogg .ogv AddType video/mp4 .mp4 AddType video/webm .webm
That’s it, it’s relatively simple. For more specific instructions on how to use video, you can search for it, or see this article. Further reading links will not be repeated here.
Step Three: Make compatibility for old browsers
As mentioned before, if the browser does not support video, it will Display the prompt content in the video. So for old browsers, we can replace this prompt content with traditional flash. In this way, when the browser is not compatible with the video tag, the flash version of the video will be displayed. For example:
<video width=”800” height=”374”> <source src=”my_video.mp4” type=”video/mp4” /> <source src=”my_video.ogv” type=”video/ogg” /> <object width="800" height="374" type="application/x-shockwave-flash" data="fallback.swf"> <param name="movie" value="fallback.swf" /> <param name="flashvars" value="autostart=true&file=video.flv" /> </object> </video>
can be directly written into the video tag according to the original normal flash introduction method. In this way, we have achieved cross-browser compatible video function usage
The above is the entire content of this article. I hope it will be helpful to everyone's learning. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
About the control analysis of H5 new attributes audio and video
HTML5
Method to implement full screen (fullScreen) of video player
HTML5
Playback control of video tag
The above is the detailed content of Sharing of plans to enhance browser compatibility of the video tag in HTML5. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

HTML5 is a key technology for building modern web pages, providing many new elements and features. 1. HTML5 introduces semantic elements such as, , etc., which enhances web page structure and SEO. 2. Support multimedia elements and embed media without plug-ins. 3. Forms enhance new input types and verification properties, simplifying the verification process. 4. Offer offline and local storage functions to improve web page performance and user experience.

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.

H5 is not just the abbreviation of HTML5, it represents a wider modern web development technology ecosystem: 1. H5 includes HTML5, CSS3, JavaScript and related APIs and technologies; 2. It provides a richer, interactive and smooth user experience, and can run seamlessly on multiple devices; 3. Using the H5 technology stack, you can create responsive web pages and complex interactive functions.

The Installation, Configuration and Optimization Guide for HDFS File System under CentOS System This article will guide you how to install, configure and optimize Hadoop Distributed File System (HDFS) on CentOS System. HDFS installation and configuration Java environment installation: First, make sure that the appropriate Java environment is installed. Edit /etc/profile file, add the following, and replace /usr/lib/java-1.8.0/jdk1.8.0_144 with your actual Java installation path: exportJAVA_HOME=/usr/lib/java-1.8.0/jdk1.8.0_144exportPATH=$J

When developing websites using CraftCMS, you often encounter resource file caching problems, especially when you frequently update CSS and JavaScript files, old versions of files may still be cached by the browser, causing users to not see the latest changes in time. This problem not only affects the user experience, but also increases the difficulty of development and debugging. Recently, I encountered similar troubles in my project, and after some exploration, I found the plugin wiejeben/craft-laravel-mix, which perfectly solved my caching problem.

Nginx performance monitoring and troubleshooting are mainly carried out through the following steps: 1. Use nginx-V to view version information, and enable the stub_status module to monitor the number of active connections, requests and cache hit rate; 2. Use top command to monitor system resource occupation, iostat and vmstat monitor disk I/O and memory usage respectively; 3. Use tcpdump to capture packets to analyze network traffic and troubleshoot network connection problems; 4. Properly configure the number of worker processes to avoid insufficient concurrent processing capabilities or excessive process context switching overhead; 5. Correctly configure Nginx cache to avoid improper cache size settings; 6. By analyzing Nginx logs, such as using awk and grep commands or ELK

Configuring an HTTPS server on a Debian system involves several steps, including installing the necessary software, generating an SSL certificate, and configuring a web server (such as Apache or Nginx) to use an SSL certificate. Here is a basic guide, assuming you are using an ApacheWeb server. 1. Install the necessary software First, make sure your system is up to date and install Apache and OpenSSL: sudoaptupdatesudoaptupgradesudoaptinsta

There are many ways to monitor the status of HDFS (Hadoop Distributed File System) on CentOS systems. This article will introduce several commonly used methods to help you choose the most suitable solution. 1. Use Hadoop’s own WebUI, Hadoop’s own Web interface to provide cluster status monitoring function. Steps: Make sure the Hadoop cluster is up and running. Access the WebUI: Enter http://:50070 (Hadoop2.x) or http://:9870 (Hadoop3.x) in your browser. The default username and password are usually hdfs/hdfs. 2. Command line tool monitoring Hadoop provides a series of command line tools to facilitate monitoring
