Permalink
Browse files

Made Audio class use URLLoader.

  • Loading branch information...
1 parent 1adb2bd commit 12e13eb825f96ac45af27ebc6cfd569ad977775f @mbebenita mbebenita committed Dec 21, 2012
View
@@ -1,7 +1,7 @@
default:
@echo "run: make [check-system|install-utils|install-libs|build-tamarin-tests|"
@echo " build-playerglobal|build-extension|build-web|"
- @echo " test|push-test|build-bot|start-build-bot]"
+ @echo " test|push-test|build-bot|start-build-bot|update-flash-refs]"
check-system:
echo "Checking the presence of mercurial..."
Binary file not shown.
Binary file not shown.
@@ -133,6 +133,7 @@
<script src="../../src/flash/net/NetConnection.js"></script>
<script src="../../src/flash/net/NetStream.js"></script>
<script src="../../src/flash/net/Responder.js"></script>
+ <script src="../../src/flash/net/URLLoader.js"></script>
<script src="../../src/flash/net/URLRequest.js"></script>
<script src="../../src/flash/net/URLStream.js"></script>
<script src="../../src/flash/system/Capabilities.js"></script>
@@ -137,6 +137,7 @@
<script src="../../src/flash/net/NetConnection.js"></script>
<script src="../../src/flash/net/NetStream.js"></script>
<script src="../../src/flash/net/Responder.js"></script>
+ <script src="../../src/flash/net/URLLoader.js"></script>
<script src="../../src/flash/net/URLRequest.js"></script>
<script src="../../src/flash/net/URLStream.js"></script>
<script src="../../src/flash/system/Capabilities.js"></script>
@@ -117,6 +117,7 @@
<script src="../flash/net/NetConnection.js"></script>
<script src="../flash/net/NetStream.js"></script>
<script src="../flash/net/Responder.js"></script>
+ <script src="../flash/net/URLLoader.js"></script>
<script src="../flash/net/URLRequest.js"></script>
<script src="../flash/net/URLStream.js"></script>
<script src="../flash/system/Capabilities.js"></script>
View
@@ -1,48 +1,49 @@
-function readBinaryFile(path, complete) {
- new BinaryFileReader(path).readAll(null, complete);
-}
+var SoundDefinition = (function () {
-function getDirectory(path) {
- var elements = path.split("/");
- return elements.slice(0, elements.length - 1).join("/");
-}
+ var audioElement = document.createElement('audio');
-var SoundDefinition = (function () {
var def = {
initialize: function initialize() {
this._playQueue = [];
this._url = null;
this._length = 0;
- this._bytesLoaded = 0;
this._bytesTotal = 0;
+ this._bytesLoaded = 0;
},
close: function close() {
throw 'Not implemented: close';
},
+
extract: function extract(target, length, startPosition) {
//extract(target:ByteArray, length:Number, startPosition:Number = -1):Number
throw 'Not implemented: extract';
},
+
_load: function _load(request, checkPolicyFile, bufferTime) {
if (!request) {
return;
}
- // (stream:URLRequest, checkPolicyFile:Boolean, bufferTime:Number) -> void
- var path = getDirectory(remoteFile) + "/" + request.url;
+
var _this = this;
- readBinaryFile(path, function (buffer) {
- _this.buffer = buffer;
- _this.dispatchEvent(new flash.events.Event("complete"));
+ var loader = this._loader = new flash.net.URLLoader(request);
+ loader.dataFormat = "binary";
+
+ loader.addEventListener("progress", function (event) {
+ console.info("PROGRESS");
+ _this.dispatchEvent(event);
+ });
- var element = document.createElement('audio');
- element.src = "data:audio/mpeg;base64," + base64ArrayBuffer(buffer);
- element.load();
- element.addEventListener("loadedmetadata", function () {
+ loader.addEventListener("complete", function (event) {
+ _this.dispatchEvent(event);
+ var buffer = loader.data.a;
+ audioElement.src = "data:audio/mpeg;base64," + base64ArrayBuffer(buffer);
+ audioElement.load();
+ audioElement.addEventListener("loadedmetadata", function () {
_this._length = this.duration * 1000;
});
- _this._playQueue.forEach(function (queueItem) {
- playChannel(buffer, queueItem.channel, queueItem.startTime, queueItem.soundTransform);
+ _this._playQueue.forEach(function (item) {
+ playChannel(buffer, item.channel, item.startTime, item.soundTransform);
});
});
},
@@ -62,17 +63,17 @@ var SoundDefinition = (function () {
startTime: startTime,
soundTransform: soundTransform
});
- if (this.buffer) {
- playChannel(this.buffer, channel, startTime, soundTransform);
+ if (this._loader.data) {
+ playChannel(this._loader.data.a, channel, startTime, soundTransform);
}
return channel;
},
get bytesLoaded() {
- return this._bytesLoaded;
+ return this._loader.bytesLoaded;
},
get bytesTotal() {
- return this._bytesTotal;
+ return this._loader.bytesTotal;
},
get id3() {
throw 'Not implemented: id3';
View
@@ -0,0 +1,26 @@
+var URLLoaderDefinition = (function () {
+ return {
+ // (request:URLRequest = null)
+ initialize: function () {
+ },
+ __glue__: {
+ native: {
+ static: {
+ },
+ instance: {
+ }
+ },
+ script: {
+ static: {
+ // ...
+ },
+ instance: {
+ data: "public data",
+ dataFormat: "public dataFormat",
+ bytesTotal: "public bytesTotal",
+ bytesLoaded: "public bytesLoaded"
+ }
+ }
+ }
+ };
+}).call(this);
View
@@ -141,6 +141,7 @@ var as3error = {};
M("flash.net.Responder", "ResponderClass", ResponderDefinition),
M("flash.net.URLRequest", "URLRequestClass", URLRequestDefinition),
M("flash.net.URLStream", "URLStreamClass", URLStreamDefinition),
+ M("flash.net.URLLoader", "URLLoaderClass", URLLoaderDefinition),
M("flash.system.FSCommand", "FSCommandClass", FSCommandDefinition),
M("flash.system.Capabilities", "CapabilitiesClass", CapabilitiesDefinition),
View
@@ -125,6 +125,7 @@
<script src="../../src/flash/net/NetConnection.js"></script>
<script src="../../src/flash/net/NetStream.js"></script>
<script src="../../src/flash/net/Responder.js"></script>
+ <script src="../../src/flash/net/URLLoader.js"></script>
<script src="../../src/flash/net/URLRequest.js"></script>
<script src="../../src/flash/net/URLStream.js"></script>
<script src="../../src/flash/system/Capabilities.js"></script>
@@ -35,7 +35,7 @@ list.sort();
content = content.replace(/(Autogenerated flash references:.*?\n)[\S\s]*?(\n\s+<!-- Autogenerated flash references end)/,
function (all, head, tail) {
return head + lineStart + list.join(lineEnd + '\n' + lineStart) + lineEnd + tail;
- });
-
-fs.writeFile(filePath, content, 'utf8');
+ }
+);
+fs.writeFile(filePath, content, 'utf8');

0 comments on commit 12e13eb

Please sign in to comment.