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

🎉 (initial commit with a parametrable watermark)

parents
node_modules
.cache
# Player Watermark plugin
A plugin that adds a watermark to the video player on your instance player.
Also a good demonstrator of how to add imports to your PeerTube plugin, and
how to modify the player.
![](http://lutim.cpy.re/MPv8mLIP.png)
.video-js.vjs-watermark {
display: block;
}
.video-js .vjs-watermark-content {
opacity: 0.99;
position: absolute;
padding: 5px;
-webkit-transition: visibility 1s, opacity 1s;
-moz-transition: visibility 1s, opacity 1s;
-ms-transition: visibility 1s, opacity 1s;
-o-transition: visibility 1s, opacity 1s;
transition: visibility 1s, opacity 1s;
}
.video-js .vjs-watermark-top-right {
right: 0;
top: 0;
}
.video-js .vjs-watermark-top-left {
left: 0;
top: 0;
}
.video-js .vjs-watermark-bottom-right {
right: 0;
bottom: 30px;
}
.video-js .vjs-watermark-bottom-left {
left: 0;
bottom: 30px;
}
.video-js.vjs-user-inactive.vjs-playing .vjs-watermark-fade {
opacity: 0;
}
.vjs-watermark-content > a:nth-child(1) img,
.vjs-watermark-content > img:nth-child(1) {
max-width: 100%;
width: 20vw;
max-height: 12vh;
position: relative;
top: 1rem;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
function register({ registerHook, peertubeHelpers }) {
initWatermark(registerHook, peertubeHelpers)
.catch(err => console.error('Cannot initialize Watermark', err))
}
export { register }
function initWatermark (registerHook, peertubeHelpers) {
return peertubeHelpers.getSettings()
.then(s => {
if (!s || !s['watermark-image-url']) {
console.error('Watermark image not set for videos.')
return
}
const image = s["watermark-image-url"]
let url = (typeof s["watermark-target-url"] !== 'undefined') ? s["watermark-target-url"] : null
registerHook({
target: "action:video-watch.video.loaded",
handler: params => {
const watermark = require("videojs-watermark")
params.videojs.registerPlugin("watermark", watermark)
}
})
registerHook({
target: "action:video-watch.player.loaded",
handler: params => {
console.log(image, url)
params.player.watermark({ image, url })
}
})
})
}
\ No newline at end of file
async function register({ registerSetting, peertubeHelpers }) {
registerSetting({
name: "watermark-image-url",
label: "Watermark image URL (.png, .jpg)",
type: "input",
private: false,
})
registerSetting({
name: "watermark-target-url",
label: "Watermark target URL",
type: "input",
private: false
})
}
async function unregister() {
return
}
module.exports = {
register,
unregister
}
This diff is collapsed.
{
"name": "peertube-plugin-player-watermark",
"version": "0.0.1",
"description": "A PeerTube plugin that adds a watermark to the video player on your instance",
"engine": {
"peertube": ">=2.0.0"
},
"keywords": [
"peertube",
"plugin"
],
"homepage": "https://framagit.org/framasoft/peertube/official-plugins/tree/master/peertube-plugin-hello-world",
"author": "Rigel Kent",
"bugs": "https://framagit.org/framasoft/peertube/official-plugins/issues",
"library": "./main.js",
"staticDirs": {},
"css": [
"assets/style.css"
],
"clientScripts": [
{
"script": "client/video-watch-client-plugin-out.js",
"scopes": [
"video-watch"
]
}
],
"translations": {},
"dependencies": {
"videojs-watermark": "^2.0.0"
},
"scripts": {
"build": "webpack --mode=production"
},
"devDependencies": {
"@purtuga/esm-webpack-plugin": "^1.1.1",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
}
}
const webpack = require("webpack")
const path = require("path")
const EsmWebpackPlugin = require("@purtuga/esm-webpack-plugin")
let config = {
entry: "./client/video-watch-client-plugin.js",
output: {
path: path.resolve(__dirname, "./client"),
filename: "./video-watch-client-plugin-out.js",
library: "script",
libraryTarget: "var"
},
plugins: [
new EsmWebpackPlugin()
]
}
module.exports = config
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