diff options
author | Robin Appelman <robin@icewind.nl> | 2016-12-03 00:38:45 +0300 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2016-12-03 00:38:45 +0300 |
commit | 8f038bb25466a19cc0b3f49222c6351682e96c85 (patch) | |
tree | 957bf5f38f0c40571807494056025d454f0ec569 /js/viewer.js | |
parent | ee36769e0b8b0857fc5fde710315acf5fea10591 (diff) |
rich sidebar previews in the sidebar
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'js/viewer.js')
-rwxr-xr-x | js/viewer.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/js/viewer.js b/js/viewer.js index 63f32c5..18baf09 100755 --- a/js/viewer.js +++ b/js/viewer.js @@ -115,3 +115,50 @@ $(document).ready(function(){ } }); + +(function () { + + var SidebarPreview = function () { + }; + + SidebarPreview.prototype = { + attach: function (manager) { + var handler = this.handlePreview.bind(this); + $.each(videoViewer.mimeTypes, function (key, value) { + if (value !== 'text') { // let the regular text preview handle this + manager.addPreviewHandler(value, handler); + } + }); + }, + + handlePreview: function (model, $thumbnailDiv, $thumbnailContainer, fallback) { + var video = document.createElement('video'); + if (video.canPlayType(model.get('mimetype'))) { + $thumbnailContainer.addClass('large'); + $thumbnailDiv.removeClass('icon-32'); + $thumbnailDiv.children('.stretcher').remove(); + video.src = OC.linkToRemoteBase('files' + model.getFullPath()); + video.autoplay = true; + video.muted = true; + video.loop = true; + video.addEventListener('loadeddata', function () { + $thumbnailDiv.removeClass('icon-loading'); + setTimeout(video.play.bind(video), 100); + }); + $thumbnailDiv.append(video); + video.load(); + video.onclick = function() { + if (video.paused) { + video.play(); + } else { + video.pause(); + } + }; + } else { + fallback(); + } + } + }; + + OC.Plugins.register('OCA.Files.SidebarPreviewManager', new SidebarPreview()); +})(); |