在video.js播放器上制作水印,使其成为播放和停止的听众

时间:2016-04-08 10:22:34

标签: javascript listener video.js playback

我设法在video.js播放器中获得了水印图像(请参阅。我需要添加什么?

下面的代码是控制台中播放器html的缩短版本



    <div class="container_video">
        <div class=
        "video-js vjs-paused my-video_0-dimensions vjs-controls-enabled vjs-workinghover vjs-user-inactive"
        id="my-video_0">
            <video class="vjs-tech" id="my-video_0_html5_api" preload="auto"
            src="files/videosxy.mp4"><source src="files/videosxy.mp4" title=
            "2.1 Knochen.mp4" type="video/mp4"></video>
            <div></div>
            <div class="vjs-poster vjs-hidden" tabindex="-1"></div>
            <div class="vjs-text-track-display vjs-hidden"></div>
            <div class="vjs-loading-spinner" dir="ltr"></div>
            <img class="watermark" src="files/video_watermarks/1.png" style="opacity: 0.5; width: 100%;">
            <button aria-live="polite" class="vjs-big-play-button" type="button"><span class="vjs-control-text">Play Video</span></button>
            <div class="vjs-control-bar" dir="ltr" role="group">
                <button aria-live="polite" class=
                "vjs-play-control vjs-control vjs-button" type=
                "button"><span class="vjs-control-text">Play</span></button>
                <div aria-live="polite" class=
                "vjs-volume-menu-button vjs-menu-button vjs-menu-button-inline vjs-control vjs-button vjs-volume-menu-button-horizontal vjs-vol-3"
                role="button" tabindex="0">
                    <div class="vjs-menu">
                        <div class="vjs-menu-content">
                            <div aria-label="volume level" aria-valuemax="100"
                            aria-valuemin="0" aria-valuenow="100.00"
                            aria-valuetext="100.00%" class=
                            "vjs-volume-bar vjs-slider-bar vjs-slider vjs-slider-horizontal"
                            role="slider" tabindex="0">
                                <div class="vjs-volume-level">
                                    <span class="vjs-control-text"></span>
                                </div>
                            </div>
                        </div>
                    </div><span class="vjs-control-text">Mute</span>
                </div>
                <div class="vjs-current-time vjs-time-control vjs-control">
                    <div aria-live="off" class="vjs-current-time-display">
                        <span class="vjs-control-text">Current Time</span> ...
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

我确实用视频循环和容器内的锚标签包围的水印来制作这个例子。

更新:我看到您的评论说您希望将徽标用作视频的控件。所以我刚刚用一个简单的javascript部分更新了我的剪辑:当点击徽标时,它会检查视频状态:如果暂停它会播放;如果玩它暂停。

function controlVid(){
var vid = document.getElementById("player"); 

if (vid.paused) {
vid.play(); 
}
  
else {
vid.pause(); 
}
}
.container {
  display: inline-block;
  position: relative; 
  outline: 2px dashed hotpink;
}

video {
  vertical-align: bottom;  
}

#logo {
  position: absolute;
  top: 45px;
  left: 0px;
  right: 0px;
  margin: auto;
  opacity: 0.4;
  height: 80px;
}

#logo:hover {
  opacity: 1;
}
<div class=container>
  
<video height="180" loop id="player">
  <source src="http://html5demos.com/assets/dizzy.mp4" type="video/mp4">  
  Your browser does not support HTML5 video.
</video>

  <a href=# onclick="controlVid()"><img src="https://s27.postimg.org/pjc1oyyj7/1484191470_psyduck.png" id="logo" alt="logo"></a>

</div>

  

视频来源:html5demos