-
Notifications
You must be signed in to change notification settings - Fork 142
/
example-2.html
100 lines (91 loc) · 3.26 KB
/
example-2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Recorder and Connect With SoundCloud</title>
<link rel="stylesheet" type="text/css" href="example.css" />
</head>
<body>
<script type="text/javascript" src="http://connect.soundcloud.com/2/latest.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="../recorder.js"></script>
<script>
function timecode(ms) {
var hms = {
h: Math.floor(ms/(60*60*1000)),
m: Math.floor((ms/60000) % 60),
s: Math.floor((ms/1000) % 60)
};
var tc = []; // Timecode array to be joined with '.'
if (hms.h > 0) {
tc.push(hms.h);
}
tc.push((hms.m < 10 && hms.h > 0 ? "0" + hms.m : hms.m));
tc.push((hms.s < 10 ? "0" + hms.s : hms.s));
return tc.join(':');
}
Recorder.initialize({
swfSrc: "../recorder.swf"
});
function record(){
Recorder.record({
start: function(){
//alert("recording starts now. press stop when youre done. and then play or upload if you want.");
},
progress: function(milliseconds){
document.getElementById("time").innerHTML = timecode(milliseconds);
}
});
}
function play(){
Recorder.stop();
Recorder.play({
progress: function(milliseconds){
document.getElementById("time").innerHTML = timecode(milliseconds);
}
});
}
function stop(){
Recorder.stop();
}
function upload(){
SC.connect({
client_id: "aHT5HITYm8vlkWNabL0Qg",
redirect_uri: "http://recorder.dev/examples/soundcloud-callback.html",
connected: function(){
Recorder.upload({
url: "https://api.soundcloud.com/tracks.json?oauth_token=" + SC.options.access_token,
audioParam: "track[asset_data]",
params: {
"track[title]": "recorder.js track test",
"track[sharing]": "private"
},
success: function(responseText){
var track = $.parseJSON(responseText)
window.location = track.permalink_url;
}
});
},
error: function(err){
alert(err)
}
})
}
</script>
<div id="wrapper">
<h1><a href="http://github.com/jwagener/recorder">Recorder Example</a></h1>
<p>
This is a very basic example for the Recorder.js.
Checkout <a href="http://github.com/jwagener/recorder">GitHub</a> for details and have a look at the source for this file.
Start by clicking record:
</p>
<div>
<a href="javascript:record()" id="record" >Record</a>
<a href="javascript:play()" id="play" >Play</a>
<a href="javascript:stop()" id="stop" >Stop</a>
<a href="javascript:upload()" id="upload" >Upload to SoundCloud</a>
</div>
<span id="time">0:00</span>
</div>
</body>
</html>