zoukankan      html  css  js  c++  java
  • javascript创建节点的事件绑定

    javascript创建节点的事件绑定

    timeupdate事件是<video>中用来返回视频播放进度的事件,绑定在<video>标签返回视频播放位置(每秒计)。

    现video标签需要直接在js中创建出来,

     video = document.createElement( 'video' );

    无法直接绑定timeupdate事件。

    解决方法:

    1.直接调用  ontimeupdate

    video = document.createElement( 'video' );
    video.ontimeupdate= function() { //实时更新播放进度条和时间
                        var currentPos = video.currentTime; //Get currenttime    //当前时间
                        var maxduration = video.duration; //Get video duration   //总时间
                }

    2.<video>标签和video对象互转

    video = document.createElement( 'video' );
    var videos = $(video);
     video.on("timeupdate", function() {           //实时更新播放进度条和时间
                        var currentPos = video[0].currentTime; //Get currenttime    //当前时间
                        var maxduration = video[0].duration; //Get video duration   //总时间
                }

    附:<video>标签和video对象的区别

    将html中的<video>标签在控制台打印后结果为:

    用javascript中   video = document.createElement( 'video' );    创建一个video对象打印出来为:

    video对象就等于<video>标签对象中的video[0]。

  • 相关阅读:
    C++中的内存分配
    进程间通信(IPC)
    一段重新开始的旅程
    状态压缩模版3:地雷
    状态压缩模版2:选数
    状态压缩模版1:滑块
    后缀数组练习4:Life Forms
    后缀数组练习3:连续重复子串
    后缀数组练习2:可重叠的k次最长重复子串
    后缀数组练习1:不可重叠最长重复子串
  • 原文地址:https://www.cnblogs.com/s313139232/p/8358365.html
Copyright © 2011-2022 走看看