欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

DPlayer.js視頻播放插件使用方法

 更新時(shí)間:2021年04月19日 08:46:28   作者:Treasure map  
這篇文章主要為大家詳細(xì)介紹了JSx實(shí)現(xiàn)簡(jiǎn)單控制視頻播放倍速,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

DPlayer.js視頻播放插件簡(jiǎn)單的使用

主要用到了實(shí)現(xiàn)了:視頻播放 、監(jiān)聽(tīng)開(kāi)始、結(jié)束、暫停、播放時(shí)間、切換視頻

官方文檔:http://dplayer.js.org

效果圖:

**

注意:我是在本地起了個(gè)服務(wù),用局域網(wǎng)連接到手機(jī)測(cè)試,其中蘋果手機(jī)中,視頻的跳轉(zhuǎn)視頻位置失效,安卓手機(jī)良好,目前沒(méi)解決…后續(xù)有時(shí)間會(huì)持續(xù)更新

**

代碼部分 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">切換視頻</button>

js:

$(function () { // 初始化視頻
            const dplayer = new DPlayer({
                container: document.getElementById('dplayer'),
                video: {
                    url: 'video/001.mp4', //視頻路徑
                    pic: 'images/banner1.png', //視頻封面
                    thumbnails: 'images/banner2.png', //視頻縮略圖
                    type: 'auto'
                },
            });
            dplayer.seek('6.972618'); //跳轉(zhuǎn)到指定時(shí)間位置

            // 點(diǎn)擊切換視頻
            $('.click1').click(function () {
                switchVideos();
            })

            // 進(jìn)行監(jiān)聽(tīng)
            dplayer.on('play', function () {
                console.log("播放");
                dplayer.seek('6.972618'); //跳轉(zhuǎn)到指定時(shí)間位置
            });
            dplayer.on('pause', function () {
                console.log("暫停");
                console.log(dplayer.video.currentTime); //獲取當(dāng)前播放時(shí)間
            });
            dplayer.on('ended', function () {
                console.log("播放結(jié)束");
            });
            dplayer.on('error', function () {
                console.log("播放異常");
            });
        })

        function switchVideos() {
            // ajax發(fā)送請(qǐng)求 獲取所點(diǎn)擊的視頻數(shù)據(jù)
            // ......
            dplayer.switchVideo({
                url: 'video/002.mp4', //賦值data中的視頻URL
                pic: 'images/banner2.png', //獲取封面圖片
                thumbnails: 'images/banner2.png' //視頻縮略圖
            })
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論