How to use DPlayer.js video playback plug-in

How to use DPlayer.js video playback plug-in

DPlayer.js video player plug-in is easy to use

Mainly used to achieve: video playback, monitoring start, end, pause, play time, switch video

Official documentation: http://dplayer.js.org

Effect picture:

**

Note: I set up a service locally and used the LAN to connect to the phone for testing. The video jump position failed on Apple phones, but it worked on Android phones. There is no solution yet... I will continue to update when I have time.

**

Code part html:

<link rel="stylesheet" href="css/dplayer.min.css">
<script src="js/dplayer.min.js"></script>
    
 <div id="dplayer" style="font-size: 12px;"></div>

<button class="click1">Switch video</button>

js:

$(function () { // Initialize video const dplayer = new DPlayer({
                container: document.getElementById('dplayer'),
                video:
                    url: 'video/001.mp4', //Video path pic: 'images/banner1.png', //Video cover thumbnails: 'images/banner2.png', //Video thumbnail type: 'auto'
                },
            });
            dplayer.seek('6.972618'); // Jump to the specified time position // Click to switch the video $('.click1').click(function () {
                switchVideos();
            })

            // Listen for dplayer.on('play', function () {
                console.log("play");
                dplayer.seek('6.972618'); //jump to the specified time position});
            dplayer.on('pause', function () {
                console.log("pause");
                console.log(dplayer.video.currentTime); //Get the current playback time});
            dplayer.on('ended', function () {
                console.log("playback ended");
            });
            dplayer.on('error', function () {
                console.log("playback abnormality");
            });
        })

        function switchVideos() {
            // ajax sends a request to obtain the clicked video data // ......
            dplayer.switchVideo({
                url: 'video/002.mp4', //Assign the video URL in data
                pic: 'images/banner2.png', //Get the cover image thumbnails: 'images/banner2.png' //Video thumbnail})
}

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of how to use the Js video player plug-in Video.js
  • How to use the flv video player plug-in of js
  • Website flv video playback plug-in code based on js and flash

<<:  Introduction to the use and disabling of transparent huge pages in Linux

>>:  Navicat for MySQL scheduled database backup and data recovery details

Recommend

Detailed explanation of the problem when combining CSS ellipsis and padding

Text truncation with CSS Consider the following c...

How to display percentage and the first few percent in MySQL

Table of contents Require Implementation Code dat...

Tutorial on installing JDK Tomcat MySQL on Linux (remote access using Mac)

One environment Alibaba Cloud Server: CentOS 7.4 ...

MySQL paging query optimization techniques

In applications with paging queries, queries that...

Steps and pitfalls of upgrading linux mysql5.5 to mysql5.7

Table of contents Linux MySQL 5.5 upgraded to MyS...

Detailed explanation of the role of static variables in MySQL

Detailed explanation of the role of static variab...

Linux installation MySQL tutorial (binary distribution)

This tutorial shares the detailed steps of instal...

New settings for text and fonts in CSS3

Text Shadow text-shadow: horizontal offset vertic...

JS achieves five-star praise case

This article shares the specific code of JS to ac...

Slot arrangement and usage analysis in Vue

The operating environment of this tutorial: Windo...

Multiple solutions for cross-domain reasons in web development

Table of contents Cross-domain reasons JSONP Ngin...

About the problem of offline installation of Docker package on CentOS 8.4

The virtual machine used is CentOS 8.4, which sim...

The difference between where and on in MySQL and when to use them

When I was writing join table queries before, I a...