Disable autoplay on embedded viewers

This commit is contained in:
2021-03-11 18:52:55 +01:00
parent bfbea8f591
commit 2d56c9c228
4 changed files with 14 additions and 9 deletions

View File

@@ -50,6 +50,7 @@ maintenance_mode = false
// Init initializes the Pixeldrain Web UI controllers
func Init(r *httprouter.Router, prefix string, setLogLevel bool) {
log.Colours = true
log.Info("Starting web UI server (PID %v)", os.Getpid())
// Seed the RNG

View File

@@ -1,7 +1,7 @@
function AudioViewer(viewer, file, next) {
this.viewer = viewer
this.file = file
this.next = next
this.file = file
this.next = next
this.container = document.createElement("div")
this.container.classList = "image-container"
@@ -17,10 +17,12 @@ function AudioViewer(viewer, file, next) {
this.container.appendChild(document.createElement("br"))
this.element = document.createElement("audio")
this.element.autoplay = "autoplay"
this.element.controls = "controls"
this.element.style.width = "90%"
this.element.addEventListener("ended", () => { this.next() }, false)
if (!embeddedViewer) {
this.element.autoplay = "autoplay"
}
this.source = document.createElement("source")
this.source.src = this.file.get_href
@@ -28,6 +30,6 @@ function AudioViewer(viewer, file, next) {
this.container.appendChild(this.element)
}
AudioViewer.prototype.render = function(parent) {
AudioViewer.prototype.render = function (parent) {
parent.appendChild(this.container)
}

View File

@@ -1,16 +1,18 @@
function VideoViewer(viewer, file, next) {
this.viewer = viewer
this.file = file
this.next = next
this.file = file
this.next = next
this.vidContainer = document.createElement("div")
this.vidContainer.classList = "image-container"
this.vidElement = document.createElement("video")
this.vidElement.autoplay = "autoplay"
this.vidElement.controls = "controls"
this.vidElement.classList = "center drop_shadow"
this.vidElement.addEventListener("ended", () => { this.next() }, false)
if (!embeddedViewer) {
this.vidElement.autoplay = "autoplay"
}
this.videoSource = document.createElement("source")
this.videoSource.src = this.file.get_href
@@ -19,6 +21,6 @@ function VideoViewer(viewer, file, next) {
this.vidContainer.appendChild(this.vidElement)
}
VideoViewer.prototype.render = function(parent) {
VideoViewer.prototype.render = function (parent) {
parent.appendChild(this.vidContainer)
}

View File

@@ -152,7 +152,7 @@ func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) {
f.FieldVal("username"),
f.FieldVal("password"),
); err != nil {
log.Error("Error while logging in: %s", err)
log.Debug("Login failed: %s", err)
formAPIError(err, &f)
} else {
// Request was a success