This repository has been archived by the owner on Dec 17, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show a thumbnail when the user hovers over the progress bar. It doesn't move yet or adjust itself to the mouse position.
- Loading branch information
Showing
6 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Video.js Thumbnails Example</title> | ||
<link href="node_modules/video-js/4.0.0-pre/video-js.css" rel="stylesheet"> | ||
<link href="videojs.thumbnails.css" rel="stylesheet"> | ||
<style> | ||
p { | ||
background-color: #eee; | ||
border: thin solid #777; | ||
padding: 10px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>The thumbnails plugin displays a series of images over the player | ||
progress bar when the viewer hovers over it or drags the playhead | ||
around to seek. Give it a shot:</p> | ||
|
||
<video id='video' | ||
src='http://video-js.zencoder.com/oceans-clip.mp4' | ||
class='video-js vjs-default-skin' | ||
width='640' | ||
height='264' | ||
poster='http://video-js.zencoder.com/oceans-clip.jpg' | ||
controls> | ||
</video> | ||
<script src='node_modules/video-js/4.0.0-pre/video.js'></script> | ||
<script src='videojs.thumbnails.js'></script> | ||
<script> | ||
// initialize video.js | ||
var video = videojs('video'); | ||
|
||
// activate the thumbnail plugin | ||
video.thumbnails({ | ||
0: { | ||
style: 'width: 120px' | ||
}, | ||
10: { | ||
style: 'width: 120px; background-position: 120px 0' | ||
}, | ||
20: { | ||
style: 'width: 120px; background-position: 240px 0' | ||
}, | ||
30: { | ||
style: 'width: 120px; background-position: 360px 0' | ||
}, | ||
40: { | ||
style: 'width: 120px; background-position: 480px 0' | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "videojs-thumbnails", | ||
"description": "progress bar thumbnails plugin for video.js", | ||
"version": "0.0.1", | ||
"peerDependencies": { | ||
"video-js": "4.0" | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.vjs-thumbnail { | ||
position: absolute; | ||
bottom: 0; | ||
opacity: 0; | ||
transition: opacity .2s ease; | ||
-webkit-transition: opacity .2s ease; | ||
-moz-transition: opacity .2s ease; | ||
} | ||
.vjs-progress-control:hover .vjs-thumbnail { | ||
opacity: 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,43 @@ | ||
videojs.plugin('thumbnails', function(options) { | ||
var settings = options; | ||
}); | ||
(function() { | ||
var defaults = { | ||
0: { | ||
src: 'example-thumbnail.png' | ||
} | ||
}, | ||
extend = function() { | ||
var args, target, i, object, property; | ||
args = Array.prototype.slice.call(arguments); | ||
target = args.shift() || {}; | ||
for (i in args) { | ||
object = args[i]; | ||
for (property in object) { | ||
if (object.hasOwnProperty(property)) { | ||
if (typeof object[property] === 'object') { | ||
target[property] = extend(target[property], object[property]); | ||
} else { | ||
target[property] = object[property]; | ||
} | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
|
||
/** | ||
* register the thubmnails plugin | ||
*/ | ||
videojs.plugin('thumbnails', function(options) { | ||
var settings, img, progressControl; | ||
settings = extend(defaults, options); | ||
|
||
// create the thumbnail image | ||
img = document.createElement('img'); | ||
img.src = settings['0'].src; | ||
img.setAttribute('style', settings['0'].style || ''); | ||
img.setAttribute('class', 'vjs-thumbnail'); | ||
|
||
// add the thumbnail to the player | ||
progressControl = this.controlBar.progressControl.el(); | ||
progressControl.appendChild(img); | ||
}); | ||
})(); |