• 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]。

  • 相关阅读:
    mysql 写计数器需要注意的问题
    CSS3倒影效果
    svg path 解析
    图论-深度优先和广度优先(均非递归)
    线段树---HDU1166敌兵布阵
    线段树入门---给定多个线段求点的出现个数
    NYOJ-129 并查集
    并查集(基础)
    二叉搜索树
    堆及堆排序
  • 原文地址:https://www.cnblogs.com/s313139232/p/8358365.html
Copyright © 2020-2023  润新知