-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
261 lines (197 loc) · 7.92 KB
/
index.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css">
<link rel="stylesheet" href="style.css">
<link href='https://fonts.googleapis.com/css?family=Lato:300' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="hero">
<div class="container">
<nav class="absolute-top-right">
<ul class="nav">
<li class="nav-item">
<a class="nav-item-link" href="#music">Music</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="#about">About</a>
</li>
</ul>
</nav>
<div class="test">
<div>My name is Becky.</div>
<div>I <span class="fa fa-heart"></span> to make music.</div>
</div>
</div>
</div>
<section class="section" id="music">
<div class="container">
<h2>My music</h2>
<div class="">
<h3 class="js-title">God only knows, Darlin'</h3>
<div class="artwork js-artwork"></div>
<ul id="music-handle" class="track-list"></ul>
</div>
</div>
<div class="js-player player player-hidden">
<div class="progress-container">
<div class="progress"></div>
</div>
<div class="container">
<audio src="" controls class="js-audio"></audio>
<button class="js-pause"><span class="fa fa-pause"></span></button>
</div>
</div>
</section>
<section class="section" id="about">
<div class="container">
<h2>A bit about me</h2>
<p>This is the bit about me</p>
<p>
You can get in touch at
<a href="mailto:[email protected]">
</a>
</p>
</div>
</section>
<script src="https://connect.soundcloud.com/sdk/sdk-3.1.2.js"></script>
<script>
var clientId = '5d45ca1b3ca462fbca4106a7c6120547';
var userId = 'beckyjennings-1';
var trackList = [];
var currentStream;
SC.initialize({
client_id: clientId
});
var handle = document.getElementById('music-handle');
// var stream = new Audio();
var stream = document.querySelector('.js-audio');
stream.onloadedmetadata = function() {
console.log(stream.duration);
};
var progress = document.querySelector('.progress');
stream.addEventListener('timeupdate', function () {
var percentage = ((stream.currentTime / stream.duration));
console.log(percentage);
progress.style.transform = 'scaleX(' + percentage + ')';
});
var player = document.querySelector('.js-player');
SC.get('/users/' + userId + '/tracks').then(function(tracks){
trackList = tracks;
trackList.forEach(function (track) {
var item = document.createElement('li');
item.classList.add('track');
var btn = document.createElement('button');
btn.innerHTML = track.title;
btn.dataset.track = JSON.stringify(track);
btn.addEventListener('click', function () {
player.classList.remove('player-hidden');
var track = JSON.parse(this.dataset.track);
var artwork = document.querySelector('.artwork');
if (track.artwork_url) {
artwork.style.backgroundImage = 'url(' + track.artwork_url.replace('large', 't500x500') + ')';
}
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://api.soundcloud.com/tracks/' + track.id + '.json?client_id=' + clientId);
xhr.onload = function(){
var track = JSON.parse(xhr.responseText);
stream.src = track.stream_url + '?client_id=' + clientId;
stream.play();
currentStream = stream;
};
xhr.send();
});
item.appendChild(btn);
handle.appendChild(item);
});
});
var pauseBtn = document.querySelector('.js-pause');
function togglePlaying () {
if (stream.paused) {
pauseBtn.innerHTML = '<span class="fa fa-pause"></span>';
stream.play();
} else {
pauseBtn .innerHTML = '<span class="fa fa-play"></span>'
stream.pause();
}
}
pauseBtn.addEventListener('click', togglePlaying);
document.body.onkeyup = function(evt){
if(evt.keyCode == 32){
togglePlaying();
}
};
/*
* - autoSmoothScroll -
* Licence MIT
* Written by Gabriel Delépine
* Current version 1.3.1 (2014-10-22)
* Previous version 1.3.0 (2014-07-23)
* Previous version 1.2.0 (2014-02-13)
* Previous version 1.0.1 (2013-11-08)
* Previous version 1.0.0 (2013-10-27)
* Requirement : None, it is a framework-free function (i.e. you do not need to include any other file in your page such as jQuery)
* Fork-me on github : https://github.com/Yappli/smooth-scroll
* */
(function(window, undefined) // Code in a function to create an isolate scope
{
'use strict';
var height_fixed_header = 0, // For layout with header with position:fixed. Write here the height of your header for your anchor don't be hiden behind
speed = 500,
moving_frequency = 15, // Affects performance ! High number makes scroll more smooth
links = document.getElementsByTagName('a'),
href;
for(var i = 0; i < links.length; i++)
{
href = (links[i].attributes.href === undefined) ? null : links[i].attributes.href.nodeValue.toString();
if(href !== null && href.length > 1 && href.indexOf('#') != -1) // href.substr(0, 1) == '#'
{
links[i].onclick = function()
{
var element,
href = this.attributes.href.nodeValue.toString(),
url = href.substr(0, href.indexOf('#')),
id = href.substr(href.indexOf('#') + 1);
if (element = document.getElementById(id))
{
var hop_count = (speed - (speed % moving_frequency)) / moving_frequency, // Always make an integer
getScrollTopDocumentAtBegin = getScrollTopDocument(),
gap = (getScrollTopElement(element) - getScrollTopDocumentAtBegin) / hop_count;
if (window.history && typeof window.history.pushState == 'function')
window.history.pushState({}, undefined, url + '#' + id); // Change URL for modern browser
for (var i = 1; i <= hop_count; i++)
{
(function()
{
var hop_top_position = gap * i;
setTimeout(function(){ window.scrollTo(0, hop_top_position + getScrollTopDocumentAtBegin); }, moving_frequency * i);
})();
}
return false;
}
};
}
}
var getScrollTopElement = function(e)
{
var top = height_fixed_header * -1;
while (e.offsetParent != undefined && e.offsetParent != null)
{
top += e.offsetTop + (e.clientTop != null ? e.clientTop : 0);
e = e.offsetParent;
}
return top;
};
var getScrollTopDocument = function()
{
return window.pageYOffset !== undefined ? window.pageYOffset : document.documentElement.scrollTop !== undefined ? document.documentElement.scrollTop : document.body.scrollTop;
};
})(window);
</script>
</body>
</html>