2020-01-28 12:51:21 +01:00
|
|
|
function AudioViewer(viewer, file, next) {
|
2020-02-04 19:37:46 +01:00
|
|
|
this.viewer = viewer
|
|
|
|
this.file = file
|
|
|
|
this.next = next
|
2020-01-21 15:33:09 +01:00
|
|
|
|
2020-02-04 19:37:46 +01:00
|
|
|
this.container = document.createElement("div")
|
|
|
|
this.container.classList = "image-container"
|
|
|
|
this.container.appendChild(document.createElement("br"))
|
2020-01-21 15:33:09 +01:00
|
|
|
|
2020-02-04 19:37:46 +01:00
|
|
|
this.icon = document.createElement("img")
|
|
|
|
this.icon.src = "/res/img/mime/audio.png"
|
|
|
|
this.container.appendChild(this.icon)
|
2020-01-21 15:33:09 +01:00
|
|
|
|
2020-02-04 19:37:46 +01:00
|
|
|
this.container.appendChild(document.createElement("br"))
|
|
|
|
this.container.appendChild(document.createTextNode(this.file.name))
|
|
|
|
this.container.appendChild(document.createElement("br"))
|
|
|
|
this.container.appendChild(document.createElement("br"))
|
2020-01-21 15:33:09 +01:00
|
|
|
|
2020-02-04 19:37:46 +01:00
|
|
|
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)
|
2020-01-21 15:33:09 +01:00
|
|
|
|
2020-02-04 19:37:46 +01:00
|
|
|
this.source = document.createElement("source")
|
|
|
|
this.source.src = this.file.get_href
|
|
|
|
this.element.appendChild(this.source)
|
|
|
|
this.container.appendChild(this.element)
|
2020-01-27 16:56:16 +01:00
|
|
|
}
|
2020-01-20 19:55:51 +01:00
|
|
|
|
2020-01-28 12:51:21 +01:00
|
|
|
AudioViewer.prototype.render = function(parent) {
|
2020-02-04 19:37:46 +01:00
|
|
|
parent.appendChild(this.container)
|
2020-01-20 19:55:51 +01:00
|
|
|
}
|