Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/html/audio.js
blob: a35bbf2f444d52f1a87a63111a3e45d18b5b0f1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// HTML 5 Audio Element encapsulation
// Lionel Laské 2012 - CC BY-SA 
// See http://www.w3.org/wiki/HTML/Elements/audio for more

enyo.kind({
	name: "HTML5.Audio",
	kind: enyo.Control,
	tag: "audio",
	published: {
		src: "", crossorigin: "", preload: "auto", autoplay: false,
		mediagroup: "", loop: false, muted: "", controlsbar: false
	},

	create: function() {
		this.inherited(arguments);
		this.srcChanged();
		this.crossoriginChanged();
		this.preloadChanged();
		this.autoplayChanged();
		this.mediagroupChanged();
		this.loopChanged();
		this.mutedChanged();
		this.controlsbarChanged();
	},

	rendered: function() {
		this.inherited(arguments);
		if (this.src instanceof Array) {
			var node = this.hasNode();
			if (node != null) {
				var len = this.src.length;
				var i;
				for (i = 0; i < len ; i++) {
					var source = document.createElement("source");
					source.setAttribute("src", this.src[i]);
					node.appendChild(source);
				}
			}
		}
	},
	
	srcChanged: function() {
		if (!(this.src instanceof Array))
			this.setAttribute("src", this.src);
	},

	crossoriginChanged: function() {
		this.setAttribute("crossorigin", this.crossorigin);
	},
	
	preloadChanged: function() {
		this.setAttribute("preload", this.preload);
	},
	
	autoplayChanged: function() {
		this.setAttribute("autoplay", this.autoplay);
	},
	
	mediagroupChanged: function() {
		this.setAttribute("mediagroup", this.mediagroup);
	},

	loopChanged: function() {
		this.setAttribute("loop", this.loop);
	},
	
	mutedChanged: function() {
		if (this.muted.length != 0)
			this.setAttribute("muted", this.muted);
	},
	
	controlsbarChanged: function() {
		this.setAttribute("controls", this.controlsbar);
	},
	
	canPlayType: function(typename) {
		var node = this.hasNode();
		if (node == null)
			return false;
		return node.canPlayType(typename);
	},
	
	play: function() {
		var node = this.hasNode();
		if (node == null)
			return;	
		node.play();
	},
	
	pause: function() {
		var node = this.hasNode();
		if (node == null)
			return;		
		node.pause();
	},
	
	paused: function() {
		var node = this.hasNode();
		if (node == null)
			return false;		
		return node.paused;
	},

	ended: function() {
		var node = this.hasNode();
		if (node == null)
			return false;		
		return node.ended;
	}	
});