-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With files encapsulated as objects, we can store them, sort them, and pass them around. This is laying a foundation for handling playlists. (#10) Also, we move the modification of the loading state outside of the skin manager. This creates a better separation of concerns.
- Loading branch information
1 parent
4ac0ac0
commit c864300
Showing
6 changed files
with
68 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Custom object representing a file | ||
// `File` is already a builtin, so we use `MyFile` | ||
MyFile = function(){ | ||
this.reader = new FileReader(); | ||
this.url = null; | ||
this.fileReference = null; | ||
this.setUrl = function(url){ | ||
this.url = url; | ||
} | ||
this.setFileReference = function(fileReference){ | ||
this.fileReference = fileReference; | ||
} | ||
this.processBuffer = function(bufferHandler) { | ||
if(this.url) { | ||
var oReq = new XMLHttpRequest(); | ||
oReq.open("GET", this.url, true); | ||
oReq.responseType = "arraybuffer"; | ||
|
||
oReq.onload = function (oEvent) { | ||
var arrayBuffer = oReq.response; // Note: not oReq.responseText | ||
bufferHandler(arrayBuffer); | ||
}; | ||
|
||
oReq.send(null); | ||
return | ||
|
||
} else if(this.fileReference) { | ||
this.reader.onload = function (e) { | ||
var arrayBuffer = e.target.result; | ||
bufferHandler(arrayBuffer); | ||
}; | ||
this.reader.onerror = function (e) { | ||
console.error(e); | ||
}; | ||
|
||
this.reader.readAsArrayBuffer(this.fileReference); | ||
return | ||
} | ||
|
||
console.error('Tried to process an unpopulated file object'); | ||
return false; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters