js/audio.js
author Ryan Willoughby <ryan.willoughby@nitobi.com>
Tue, 06 Jul 2010 11:31:19 -0700
changeset 0 54063d8b0412
permissions -rwxr-xr-x
initial commit of PhoneGap WRT framework, licensing and test code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
     1
/**
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
     2
 * This class provides access to the device media, interfaces to both sound and video
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
     3
 * @constructor
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
     4
 */
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
     5
function Audio(src, successCallback, errorCallback) {
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
     6
	this.src = src;
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
     7
	this.successCallback = successCallback;
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
     8
	this.errorCallback = errorCallback;												
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
     9
}
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    10
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    11
Audio.prototype.record = function() {
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    12
};
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    13
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    14
Audio.prototype.play = function() {
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    15
try {
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    16
	if (document.getElementById('gapsound'))
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    17
		document.body.removeChild(document.getElementById('gapsound'));
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    18
	var obj;
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    19
	obj = document.createElement("embed");
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    20
	obj.setAttribute("id", "gapsound");
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    21
	obj.setAttribute("type", "audio/x-mpeg");
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    22
	obj.setAttribute("width", "0");
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    23
	obj.setAttribute("width", "0");
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    24
	obj.setAttribute("hidden", "true");
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    25
	obj.setAttribute("autostart", "true");
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    26
	obj.setAttribute("src", this.src);
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    27
	document.body.appendChild(obj);
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    28
} catch (ex) { debug.log(ex.name + ": " + ex.message); }
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    29
};
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    30
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    31
Audio.prototype.pause = function() {
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    32
};
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    33
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    34
Audio.prototype.stop = function() {
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    35
	document.body.removeChild(document.getElementById('gapsound'));
54063d8b0412 initial commit of PhoneGap WRT framework, licensing and test code
Ryan Willoughby <ryan.willoughby@nitobi.com>
parents:
diff changeset
    36
};