-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaudiotest.html
129 lines (122 loc) · 3.18 KB
/
audiotest.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css">
<style>
.audiotitle {
display: inline-block;
width: 80px;
text-align: right;
margin-right: 10px;
}
.volume-container {
display: inline-block;
width: 200px;
margin: 0 20px;
position: relative;
top: 4px;
}
.play, .stop, .zero {
vertical-align: top;
}
</style>
<script src="js/jquery-1.8.2.min.js"></script>
<script src="js/jquery-ui-1.9.2.min.js"></script>
<script>
var soundbedVolume = 1;
var bellVolume = 1;
var audioFadeIn = function($obj){
$obj[0].volume = 0;
$obj.trigger('play');
$obj.animate({volume: soundbedVolume}, 1000);
}
var audioFadeOut = function($obj){
$obj.animate({volume: 0}, 1000, function(){
$obj.trigger('pause');
});
}
var zeroTime = function($obj){
$obj[0].currentTime = 0;
}
var adjustVolume = function($obj,volume){
if (!($obj instanceof jQuery)) {
var $this = $(this);
$obj = $($this.attr('rel')).eq(0);
volume = $this.slider('value');
}
$obj.siblings('.display').html(volume);
$obj[0].volume = volume / 100;
}
// var getVolume = function($obj){
// if (!($obj instanceof jQuery)) {
// var $this = $(this);
// $obj = $($this.attr('rel')).eq(0);
// }
// return $obj[0].volume * 100;
// }
$(document).ready(function(){
$('.volume').slider({
range: 'min'
,min: 0
,max: 100
,value: 100
,slide: adjustVolume
,change: adjustVolume
,create: adjustVolume
});
$('.play').on('click',function(event){
event.preventDefault();
var $audioObj = $($(this).attr('rel')).eq(0);
audioFadeIn($audioObj);
});
$('.stop').on('click',function(event){
event.preventDefault();
var $audioObj = $($(this).attr('rel')).eq(0);
audioFadeOut($audioObj);
});
$('.zero').on('click',function(event){
event.preventDefault();
var $audioObj = $($(this).attr('rel')).eq(0);
zeroTime($audioObj);
});
});
</script>
</head>
<body>
<div id="soundbedControls">
<audio id="soundbed" loop preload="auto">
<source src="video/TBR_LoopLong_OptionA.mp3" type="audio/mpeg">
<source src="video/TBR_LoopLong_OptionA.wav" type="audio/wav">
</audio>
<div class="audiotitle">
Soundbed
</div>
<button class="play" rel="#soundbed">►</button>
<button class="stop" rel="#soundbed">◼</button>
<button class="zero" rel="#soundbed"><<</button>
<div class="volume-container">
<div class="volume" rel="#soundbed"></div>
</div>
<span class="display"></span>
</div>
<br>
<div id="bellControls">
<audio id="bell" loop preload="auto">
<source src="video/TBR_RINGLOOP_02_v05_SFX.mp3" type="audio/mpeg">
<source src="video/TBR_RINGLOOP_02_v05_SFX.wav" type="audio/wav">
</audio>
<div class="audiotitle">
Bell
</div>
<button class="play" rel="#bell">►</button>
<button class="stop" rel="#bell">◼</button>
<button class="zero" rel="#bell"><<</button>
<div class="volume-container">
<div class="volume" rel="#bell"></div>
</div>
<span class="display"></span>
</div>
</body>
</html>