Skip to content

Commit

Permalink
support videojs 5 + demo code
Browse files Browse the repository at this point in the history
  • Loading branch information
spchuang committed Oct 24, 2016
1 parent da40313 commit 2029678
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 14 deletions.
146 changes: 146 additions & 0 deletions demo/example-videojs5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<!doctype html>
<html>
<head>
<title>Video.js Markers Example</title>

<style>
p {
background-color: #eee;
border: thin solid #777;
padding: 10px;
}
.video-js{
float:left;
}
.event-list {
float:left;
border: black;
margin-left: 5px;
width: 200px;

}
.control{
clear: both;
}
</style>
<link href="http://vjs.zencdn.net/5.11.8/video-js.css" rel="stylesheet">
<link href="../dist/videojs.markers.css" rel="stylesheet">

</head>
<body>

<p>This is a demo of video-markers plugin for videojs 5</p>

<div>
<video id="test_video" controls preload="none" class="video-js vjs-default-skin" width="640" height="264">
<source src="http://vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
<source src="http://vjs.zencdn.net/v/oceans.webm" type="video/webm">
</video>
<div class='event-list'>
<div><b>Events: </b></div>
</div>
</div>

<div class="control">
<div class='next'>Next</div>
<div class='prev'>Prev</div>
<div class='remove'>Remove</div>
<div class='add'>Add</div>
<div class='updateTime'>Move all markers right by 1 sec</div>
<div class='reset'>Reset</div>
<div class='destroy'>Destroy</div>
</div>
</body>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="http://vjs.zencdn.net/5.11.8/video.js"></script>
<script src='../dist/videojs-markers.js'></script>

<script>
// initialize video.js
var player = videojs('test_video');

//load the marker plugin
player.markers({
markerTip:{
display: true,
text: function(marker) {
return "This is a break: " + marker.text;
}
},
breakOverlay:{
display: true,
displayTime: 3,
text: function(marker) {
return "This is an break overlay: " + marker.text;
}
},
onMarkerReached: function(marker) {
$('.event-list').append("<div>marker reached: " + marker.text + "</div>");

},
onMarkerClick: function(marker){
$('.event-list').append("<div>marker clicked: " + marker.text + "</div>");

},
markers: [
{
time: 9.5,
text: "this"
},
{
time: 16,
text: "is"
},
{
time: 23.6,
text: "so"
},
{
time: 28,
text: "cool"
},
{
time: 36,
text: ":)"
}
]
});

$(".next").click(function(){
player.markers.next();
});
$(".prev").click(function(){
player.markers.prev();
});
$(".remove").click(function(){
player.markers.remove([0,1]);
})
$(".add").click(function(){
player.markers.add([{
time: 25,
text: "I'm NEW"
}]);
});
$(".updateTime").click(function(){
var markers = player.markers.getMarkers();
for (var i = 0; i < markers.length; i++) {
markers[i].time += 1;
}
player.markers.updateTime();
});

$(".reset").click(function(){
player.markers.reset([{
time: 40,
text: "I'm NEW"
},
{
time:20,
text: "Brand new"
}]);
});
$(".destroy").click(function(){
player.markers.destroy();
})
</script>
</html>
8 changes: 4 additions & 4 deletions dist/videojs-markers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/videojs-markers.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/videojs-markers.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/videojs.markers.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
transition: opacity .2s ease;
-webkit-transition: opacity .2s ease;
-moz-transition: opacity .2s ease;
z-index: 100;
}
.vjs-marker:hover {
cursor: pointer;
Expand Down
2 changes: 1 addition & 1 deletion dist/videojs.markers.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "videojs-markers",
"description": "video marker breaks plugin for video.js",
"version": "0.6.0",
"version": "0.7.0",
"peerDependencies": {
"video-js": "4.0",
"jquery": "1.10.2"
Expand Down
6 changes: 3 additions & 3 deletions src/videojs.markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type Marker = {
newMarkers.forEach((marker: Marker) => {
marker.key = generateUUID();

videoWrapper.find('.vjs-progress-control')
videoWrapper.find('.vjs-progress-holder')
.append(createMarkerDiv(marker));

// store marker in an internal hash map
Expand Down Expand Up @@ -198,7 +198,7 @@ type Marker = {
// margin-left needs to minus the padding length to align correctly with the marker
markerTip.css({
"left" : getPosition(marker) + '%',
"margin-left" : -parseFloat(markerTip.css("width")) / 2 - 5 + 'px',
"margin-left" : -parseFloat(markerTip.width()) / 2 - 5 + 'px',
"visibility" : "visible",
});
}
Expand All @@ -212,7 +212,7 @@ type Marker = {

function initializeMarkerTip(): void {
markerTip = $("<div class='vjs-tip'><div class='vjs-tip-arrow'></div><div class='vjs-tip-inner'></div></div>");
videoWrapper.find('.vjs-progress-control').append(markerTip);
videoWrapper.find('.vjs-progress-holder').append(markerTip);
}

// show or hide break overlays
Expand Down
4 changes: 2 additions & 2 deletions src/videojs.markers.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
transition: opacity .2s ease;
-webkit-transition: opacity .2s ease;
-moz-transition: opacity .2s ease;
z-index: 100;
&:hover{
cursor:pointer;
-webkit-transform:scale(1.3, 1.3);
Expand Down Expand Up @@ -49,7 +50,7 @@
}

.vjs-break-overlay{
visibility: hidden;
visibility: hidden;
position: absolute;
z-index: 100000;
top: 0;
Expand All @@ -58,4 +59,3 @@
text-align: center;
}
}

0 comments on commit 2029678

Please sign in to comment.