Verified Commit b5456c2c authored by Rigel Kent's avatar Rigel Kent
Browse files

basic integration of videojs-slides in PeerTube

parents
node_modules
.cache
dist
LICENSE
\ No newline at end of file
This diff is collapsed.
# PeerTube plugin Quickstart
.video-js.vjs-slides {
position: relative;
}
.video-js.vjs-slides.vjs-has-started.vjs-user-inactive.vjs-playing .vjs-control-bar {
margin-top: 20px;
}
.video-js.vjs-slides .video-footer {
margin: 0 1rem;
}
.video-js.vjs-slides .media-content .overlay-panel .slides-list li{
width: 100%;
}
.video-js.vjs-slides .video-slides-container {
width: 25%;
bottom: 10px !important;
}
.video-js.vjs-slides .video-footer .video-author img {
max-width: 20px;
}
/* Temporary, until author is properly handled */
.video-js.vjs-slides .video-footer .video-author {
visibility: hidden;
}
function register({ registerHook, peertubeHelpers }) {
initSlides(registerHook, peertubeHelpers)
.catch(err => console.error('Cannot initialize slides plugin', err))
}
export { register }
function initSlides (registerHook, peertubeHelpers) {
return peertubeHelpers.getSettings()
.then(s => {
registerHook({
target: "action:video-watch.video.loaded",
handler: params => {
window.videojs = params.videojs
// init contrib-ads
const slides = require('videojs-slides').default
params.videojs.registerPlugin('slides', slides)
}
})
registerHook({
target: "action:video-watch.player.loaded",
handler: params => {
fetch(window.location.href, { headers: new Headers({ 'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }) }).then(r => r.json())
.then(video => {
// tokenize content
const md = require("markdown").markdown
const tree = md.parse(video.content)
// console.log(tree)
const slides = tree.find(e => e != "markdown" && e[1].find(f => f == 'slides'))[2].split('\n').filter(e => e != "").map(e => e.replace("- ", "")).map(e => e.split(" ")).map(e => { return { time: hmsToSeconds(e[0]), url: e[1] }})
// console.log(slides)
const resources = tree.find(e => e != "markdown" && e[1].find(f => f == 'resources'))[2].split('\n').filter(e => e != "").map(e => e.replace("- ", "")).map(e => e.split(" ")).map(e => { return { name: (function(){ let f = [...e]; f.pop(); return f.join(" ") })(), url: [...e].pop(), cta: "view" }})
// console.log(resources)
// set slides in player
params.player.slides({
slides,
resources,
author: { name: "persed author name", image: "/client/assets/images/default-avatar.png" },
links: []
})
})
}
})
})
}
function hmsToSeconds (timestamp) {
return timestamp.split(':').reduce((acc,time) => (60 * acc) + +time);
}
{
"Hello world": "Hello le monde"
}
async function register ({
registerHook,
registerSetting,
settingsManager,
storageManager,
videoCategoryManager,
videoLicenceManager,
videoLanguageManager
}) {
}
async function unregister () {
return
}
module.exports = {
register,
unregister
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment