HTML
jQuery
video

HTML5 video playing on any web page is very easy, in this tutorial we can show you how to add video on html and make it play and pause without using html controls. I personally use this  play pause because many times we are using video to play auto animation to website

Below is the code and embed codepen to show its works:

<!DOCTYPE html>
<html>

<head>
    <title>video</title>
    <style>
        .overlay {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
        
        video#video {
            width: 100%;
        }
    </style>
</head>

<body>
    <div class="container">
        <video id="video">
            <source src="sample.mp4" type="video/mp4">
        </video>
        <div class="play overlay"><img src="play.png" /></div>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.js"></script>
    <script>
        jQuery(document).ready(function() {
            jQuery(".container").click(function() {
                if (jQuery("#video").get(0).paused) {
                    jQuery("#video").trigger('play');
                    jQuery(".play").fadeOut(500);
                } else {
                    jQuery("#video").trigger('pause');
                    jQuery(".play").fadeIn(500);
                }
            });
        });
    </script>
</body>

</html>

Codepen:

 

See the Pen PoPNvqR by key2goal (@key2goal) on CodePen.


Please Comment your thoughts and feedback below and add something if you found good in anywhere to help others

Hit a like Button If you like the Post.

Many Thanks

Comments

Add new comment

Other Articles

Uncaught TypeError: CKEDITOR.tools.object.keys is not a function

Intergation of code snippet with ckeditor, cause this error "Uncaught TypeError: CKEDITOR.tools.object.keys is not a function".

what is namespace in PHP?

https://stackoverflow.com/questions/3384204/what-are-namespaces

Render a drupal node d7

If you want to render a node in drupal 7 it is pretty easy, you just a node id or nid of node for doing this: simply

Facebook, Twitter and LinkedIn post share checker

Social media apps like Facebook, twitter linked allow your website and apps to share on there pages to reach with more peoples.

Enable Drupal 8 Error Reporting

To Enable Drupal 8 Error Reporting, Put This code at top of sites/default/settings.php.

Import and Export Drupal 8 Views, Or Import and Export any configuration Drupal 8

Import and Export configuration is the basic protocol to staging the website or production website deployment, In Drupal 7, we need the extra modules to import and export or we can use features mod

Recursively delete all files of a specific extension

Usually we all use "rm" command to delete or remove the files and folder on linux, but if we want to delete the specific type of content/files then we can use "find" command to find and "delete" co

Allow Less Secure App Yahoo Mail

hey,  If you want to read email form script you need to allow less secure app as same as Gmail,  Just Go to the link, after login and allow less secure app at the bottom.

Drupal 8 mutlisite setup

In Drupal 8 Multisite setup is almost same as the Drupal 7.

How you can get Mailchimp API KEY

By Follow steps below, you can find the api key or create the api key at mailchimp and use it to your website to connected the site with mailchimp to collect the subscribe in fastest way.

Easy Way to use tooltip with HTML tags

The easiest way to use tooltip on any tags of HTML 1. Span Tag

Facebook post customisation posted using web app using Facebook Open Graph

Facebook is Providing autoposting functionality using website application and provides to display you website content on your facebook page.

Change all files and folders permissions of a directory to 644/755

Find is best command to apply permission to directories and files recursively to all . For Directories

Drupal 8 Theming Essential Guide

What's new? I’ll list some changes with the theming system of Drupal 8 compared to Drupal 7. You may have got familiar with these in the Drupal 7 version.

Retrieve the query used in mysql views

we can create the database views for many reason, but if we forget what query you was used to create the views or need to find out using which query results are generating here is the solution:

Prevent to Load a js file on particular page using hook_js_alter Drupal 7

Drupal provided the lots of hook to extents its functionality, using this we can prevent a js file to load on particular page using HOOK_JS_ALTER

How to create the directories and sub directories in one command linux

Many times we are want to create multiple directories and sub-directories under it and usually we do cd and mkdir one by one, it is very time consuming and it sometimes slow down our workflow.

Import Database using xampp mysql command prompt windows

As we all know the xampp is most popular tool at machine level programming work, but sometime we need to deal with the bigger databases to import into mysql of xampp that provide and we import that

Get average number with PHP

<?php //put all integer in array $array = array(9,18,9,5,6,45); //Calculate the average. $average = array_sum($array) / count($array);

Reindex the Array keys

Sometimes we need to slice the array for certain values using program a code and at that time key of array is also unset. If you faced the same then you can use these options

Create a Flag link programmatically and render flag link in twig template drupal 8

This article is refer to generate the flag link programmatically and render in drupal 8 twig template, before in drupal 7 its was quiet easy to render or generate flag link in just a single line of

Export Mysql database using SSH

Export The database directly from command line is Easy and Fast. Follow these steps to export the database using SSH (putty terminal)

Fix Bug Phpmyadmin [sql.lib.php] + Php7.2 + Ubuntu 16.04

I have faced this error recently , look like this    Warning in ./libraries/sql.lib.php#601

Recent Posts

Drupal 8: check user is logged in or not in *.html.twig

In the new era the drupal8 twig is introduce, so old basic php drupal hook is not useful in theme templates.

Add text to ckeditor textarea using jquery

In most of case we need to add or fill up form fields using jquery or Js, if you have trobble in loading data in textarea having ckeditor working already then this tutorial helps you.

How to Add a Custom Date Format in Drupal 8

In drupal 8 there is easiest way to add the date format is simply go link for your website

Retrieve the query used in mysql views

we can create the database views for many reason, but if we forget what query you was used to create the views or need to find out using which query results are generating here is the solution:

Send file as Email attachment using hook_mail_alter drupal 7 programmatically (example webform submit)

Hi guys,

In this tutorial we can see how we can send files as attachments in drupal 7 on webform submit using a hook_mail_alter 

[SOLVED] PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting

If you get the same error like below in VScode editor then you are the right place to 

Redirect Old Domain to New Domain via .htaccess

Usually we develop the site on developement or subdomain and when we finally mirgate the to new domain then some of thing will remain or page redirect happens in  sometimes , so In this case .htacc

Create a Flag link programmatically and render flag link in twig template drupal 8

This article is refer to generate the flag link programmatically and render in drupal 8 twig template, before in drupal 7 its was quiet easy to render or generate flag link in just a single line of

Jquery prevent enter to submit form

If you want to prevent the form submit using jquery, then this page helps you to doing this.

Code:

Import and Export Drupal 8 Views, Or Import and Export any configuration Drupal 8

Import and Export configuration is the basic protocol to staging the website or production website deployment, In Drupal 7, we need the extra modules to import and export or we can use features mod

How to override different version of Jquery in Drupal 8 using theme

Drupal 8 use its own jquery version by default and if you want to use the other version of jQuery instead of default than this tutorials steps is for you, sometimes we need different version to oth

Subscribe to Mailchimp programmatically via api with PHP

In this tutorial we can see how to subscribe to the mailchimp subscribe list using php programmatically via api,

For this you need a mailchimp account, api key and list id