forked from pupunzi/jquery.mb.audio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
150 lines (130 loc) · 5.67 KB
/
demo.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.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</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"></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: 63, end: 75.5, 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.8, end: 8, loop: false},
divine : {id: "divine", start: 10, end: 11.6, loop: false},
wow : {id: "wow", start: 15, end: 20, 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.play('backgroundSprite', 'levelIntro');
}, 3000);
}
$(document).on("initAudio", function () {
$.mbAudio.pause('effectSprite', audioIsReady);
$('#start').hide();
$("#loading").show();
});
</script>
<style>
body {
padding: 50px;
}
button {
display: block;
margin: 30px 10px;
padding: 10px;;
}
</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>
111
<h2>jquery.mb.audio API: Using the "direct play" and the "sprite" features.</h2>
<p>To invoke the "play" event for a specific sprite:<br>
<b>$.mbAudio.play(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 || !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="$.mbAudio.play('effectSprite', 'great')">play effect 1</button>
<button style="cursor:pointer" onmousedown="$.mbAudio.play('effectSprite', 'wow')">play effect 2</button>
<button id="playSound1" style="cursor:pointer" onmousedown="$.mbAudio.play('effectSprite', 'streak')">play effect 3
(it loops 3 times)
</button>
<div id="bgndControls" style="display: none">
<button style="cursor:pointer" onclick="$.mbAudio.pause('backgroundSprite')">stop background sound</button>
<button style="cursor:pointer" onclick="$.mbAudio.play('backgroundSprite','levelIntro')">start background sound
</button>
</div>
<script>
if (!isAndroid)
$("#bgndControls").show();
</script>
<br>
<a href="demo_queue.html">See also the "Queue" demo</a>
</div>
</body>
</html>