Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Prevent downloads when video has a download limit
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed May 4, 2022
1 parent e0555bc commit 48537c3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 12 deletions.
4 changes: 2 additions & 2 deletions js/files_videoplayer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/files_videoplayer-main.js.map

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "A responsive video player for Nextcloud using a skinned version of Video.js.",
"private": true,
"dependencies": {
"@nextcloud/initial-state": "^1.2.1",
"escape-html": "^1.0.3",
"video.js": "^7.4.1"
},
Expand Down
24 changes: 15 additions & 9 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,19 @@
*/

import escapeHTML from 'escape-html'
import { loadState } from '@nextcloud/initial-state'

__webpack_nonce__ = btoa(OC.requestToken)
__webpack_public_path__ = OC.filePath('files_videoplayer', '', 'js/')

let videojs = null

const { limit } = loadState('files_downloadlimit', 'download_limit', { limit: -1 })
const hasDownloadLimit = limit !== -1

const videoViewer = {
UI: {
show() {

const source = document.createElement('source')
source.src = escapeHTML(videoViewer.location).replace('&amp;', '&')

if (videoViewer.mime) {
source.type = escapeHTML(videoViewer.mime)
}

const playerView = document.createElement('video')
playerView.id = 'my_video_1'
playerView.classList.add('video-js')
Expand All @@ -48,7 +44,17 @@ const videoViewer = {
playerView.height = '100%'
playerView.poster = OC.filePath('files_videoplayer', '', 'img') + '/poster.png'
playerView.setAttribute('data-setup', '{"techOrder": ["html5"]}')
playerView.appendChild(source)

if (!hasDownloadLimit) {
const source = document.createElement('source')
source.src = escapeHTML(videoViewer.location).replace('&amp;', '&')

if (videoViewer.mime) {
source.type = escapeHTML(videoViewer.mime)
}

playerView.appendChild(source)
}

if (videoViewer.inline === null) {
const overlay = document.createElement('div')
Expand Down

0 comments on commit 48537c3

Please sign in to comment.