mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-23 02:15:01 +00:00
Allow drag and drop playing of files
This commit is contained in:
parent
966afbd8a9
commit
08e9df067a
1 changed files with 29 additions and 4 deletions
33
winamp.js
33
winamp.js
|
|
@ -142,10 +142,7 @@ function Winamp () {
|
|||
|
||||
this.nodes.fileInput.onchange = function(e){
|
||||
var file = e.target.files[0];
|
||||
var objectUrl = URL.createObjectURL(file);
|
||||
self.loadFile(objectUrl, file.name);
|
||||
self.media.play();
|
||||
self.setStatus('play');
|
||||
self.loadFileViaReference(file);
|
||||
}
|
||||
|
||||
this.nodes.volume.oninput = function() {
|
||||
|
|
@ -219,6 +216,34 @@ function Winamp () {
|
|||
document.getElementById('second-second-digit').appendChild(html);
|
||||
}
|
||||
|
||||
|
||||
this.dragenter = function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
this.dragover = function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
this.drop = function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var dt = e.dataTransfer;
|
||||
var file = dt.files[0];
|
||||
self.loadFileViaReference(file);
|
||||
}
|
||||
|
||||
this.nodes.winamp.addEventListener('dragenter', this.dragenter);
|
||||
this.nodes.winamp.addEventListener('dragover', this.dragover);
|
||||
this.nodes.winamp.addEventListener('drop', this.drop);
|
||||
|
||||
this.loadFileViaReference = function(fileReference) {
|
||||
var objectUrl = URL.createObjectURL(fileReference);
|
||||
self.loadFile(objectUrl, fileReference.name);
|
||||
self.media.play();
|
||||
self.setStatus('play');
|
||||
}
|
||||
|
||||
this.loadFile = function(file, fileName) {
|
||||
this.media.loadFile(file);
|
||||
html = fontHtml(fileName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue