-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathdemo_queue.html
150 lines (128 loc) · 5.88 KB
/
demo_queue.html
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!doctype html>
<!--
~ /*******************************************************************************
~ jquery.mb.components
~ file: demo_queue.html
~
~ Copyright (c) 2001-2014. Matteo Bicocchi (Pupunzi);
~ Open lab srl, Firenze - Italy
~ email: [email protected]
~ site: http://pupunzi.com
~ blog: http://pupunzi.open-lab.com
~ http://open-lab.com
~
~ Licences: MIT, GPL
~ http://www.opensource.org/licenses/mit-license.php
~ http://www.gnu.org/licenses/gpl.html
~
~ last modified: 07/01/14 22.50
~ ******************************************************************************/
-->
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title>jquery.mb.audio - Queue</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="inc/jquery.mb.audio.js?_=8y338"></script>
<script type="text/javascript">
/*
* DEFINE SOUNDS
*/
$.mbAudio.sounds = {
backgroundSprite: {
id: "backgroundSprite",
ogg: "sounds/bgndsSprite.ogg",
mp3: "sounds/bgndsSprite.mp3",
//example of sprite
sprite:{
intro : {id: "intro", start: 80, end: 116.975, loop: true},
levelIntro: {id: "levelIntro", start: 60, end: 77.470, loop: true},
tellStory: {id: "tellStory", start: 80, end: 116.975, loop: true},
level1 : {id: "level1", start: 5, end: 13, loop: true},
level2 : {id: "level2", start: 40, end: 56, loop: true},
level3 : {id: "level3", start: 120, end: 136.030, loop: true}
}
},
effectSprite: {
id: "effectSprite",
ogg: "sounds/effectsSprite.ogg",
mp3: "sounds/effectsSprite1.mp3",
//example of sprite
sprite:{
streak: {id: "streak", start: 0, end: 1.3, loop: 3},
great : {id: "great", start: 5, end: 8, loop: false},
divine: {id: "divine", start: 10, end: 12, loop: false},
wow : {id: "wow", start: 15, end: 24, loop: false},
levelIntro : {id: "levelIntro", start: 20, end: 25, loop: false},
levelCompleted: {id: "levelCompleted", start: 25, end: 30, loop: false},
subLevelLost: {id: "subLevelLost", start: 35, end: 38.1, loop: false},
subLevelWon : {id: "subLevelWon", start: 30, end: 31.9, loop: false},
gameWon : {id: "gameWon", start: 30, end: 31.9, loop: false}
}
}
};
function audioIsReady(){
setTimeout(function(){
$('#buttons').fadeIn();
$("#loading").hide();
if(isStandAlone || !isDevice)
$.mbAudio.queue.add('backgroundSprite',"levelIntro");
},3000);
}
$(document).on("initAudio", function () {
$.mbAudio.pause('effectSprite', audioIsReady);
$('#start').hide();
$("#loading").show();
});
$(document).on("event1", function () {toggleButtons(); $.mbAudio.queue.add('effectSprite', 'great',toggleButtons)});
$(document).on("event2", function () {toggleButtons(); $.mbAudio.queue.add('effectSprite', 'divine',toggleButtons)});
$(document).on("event3", function () {toggleButtons(); $.mbAudio.queue.add('effectSprite', 'streak',toggleButtons)});
$(document).on("event4", function () {$.mbAudio.queue.add('backgroundSprite', 'levelIntro')});
function toggleButtons(){
$("button").toggleClass("disabled");
}
</script>
<style>
body{
padding: 50px;
}
button{
display: block;
margin: 30px 10px;
padding: 10px;
}
button.disabled{
opacity:.3;
}
</style>
</head>
<body>
<a href="https://github.com/pupunzi/jquery.mb.audio"><img style="width:100px; position: absolute; top: 20px; right: 20px; border: 0; z-index: 1000" src="http://upload.wikimedia.org/wikipedia/commons/b/b3/GitHub.svg" alt="Fork me on GitHub"></a>
<h2>jquery.mb.audio API: Using the Queue and the sprite features.</h2>
<p>To "add" a soud to the queue:<br>
<b>$.mbAudio.queue.add(audio, sprite)</b></p>
<div id="start">
<p>This button is needed to initialize audio (see the table in the documentation) [todo: wiki].</p>
<script>
if((isiOs && isStandAlone) || !isDevice){
document.write("<p>This button will also initialize the effects sprite and will play the background sprite (only iOS).</p>")
}
</script>
<button style="cursor:pointer" onmousedown="$(document).trigger('initAudio')">Lets start</button>
</div>
<div id="loading" style="display: none;">... loading ...</div>
<div id="buttons" style="display: none;">
<p>The three buttons below play sounds from the same audio file (sounds/bgndsSprite .mp3 or .ogg)</b></p>
<button style="cursor:pointer" onmousedown="$(document).trigger('event1')">play sound 1</button>
<button style="cursor:pointer" onmousedown="$(document).trigger('event2')">play sound 2</button>
<button id="playSound1" style="cursor:pointer" onmousedown="$(document).trigger('event3')">play effect 3 (it loops 3 times)</button>
<br>
<button style="cursor:pointer" onmousedown="$(document).trigger('event4')">play background</button>
<br>
<a href="demo.html">See also the "direct play" demo</a>
</div>
</body>
</html>