When developing a WordPress CMS theme, we often run into the need to play videos. Many WordPress sites still use Flash players, video plugins, or simply embed Youku or other external video services directly. In fact, WordPress’s default video player is often enough to handle video playback very well.
How to insert video in WordPress
Uploading a video in WordPress works the same way as uploading an image. While editing a post, click the Add Media button, choose the video to upload, and upload it, or drag it directly into the uploader. After the upload is complete, click Insert into post to place the video inside the article. Once inserted, the video player looks like this. Clicking the default play button lets you preview the video directly in the admin area.

After inserting the video, switch the editor to the Text view and you will find that WordPress actually inserts a shortcode. That shortcode uses the well-known video.js player. video.js checks the browser being used. If the browser supports HTML5, it uses the built-in HTML5 video player. If it does not, it falls back to the Flash player bundled with video.js. That gives very good compatibility while still using the modern browser’s native playback capability.
How to insert video through PHP code
We can use the do_shortcode function directly inside PHP code to parse and execute the video shortcode and insert a video that way.

Video formats supported by the WordPress default player
One thing to pay attention to is that video.js supports only a limited set of video formats, so it is best to convert the file before uploading it. The browsers we use most often, such as IE9+ and Chrome, support MPEG-4 files encoded with H.264 video and AAC audio. If you are converting the file with a tool such as Format Factory, choosing the MPEG-4 AVC format is usually enough.
Which themes support the WordPress default video player?
The default video player does not have any special requirements for a WordPress theme. As long as WordPress is updated to a recent version and the theme’s footer.php contains <?php wp_footer(); ?>, it will work. That is because the video.js resources used by the default player are loaded through the wp_footer hook. Some theme authors do not fully understand the importance of that function, which causes their themes to miss some core WordPress features and break compatibility with JavaScript-based plugins.
Summary: if your site does not have huge traffic and the uploaded videos are not very large, WordPress’s default player is a good choice and the user experience is solid. But if your videos are large, using a third-party video service is still a better option because serving those files directly can put a very heavy load on your server.
