Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
114 lines (100 sloc) 4.05 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rijksmuseum App</title>
<link href="css/fotorama.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/notifier.js"></script>
<script>
NotifierjsConfig.defaultTimeOut = 1000;
NotifierjsConfig.position = ["top", "right"];
</script>
<script type="text/javascript" src="js/coffee-script.js"></script>
<script type="text/javascript" src="js/underscore.js"></script>
<script type="text/javascript" src="js/backbone.js"></script>
<script type="text/javascript" src="js/jath.js"></script>
<script type="text/javascript" src="js/jade.js"></script>
<script type="text/javascript" src="js/composers.js"></script>
<script src="js/fotorama.js"></script>
<script>
function getQueryByYears(startYear, endYear) {
var artists = [];
for (var c in composers) {
start = composers[c][0];
end = composers[c][1];
if ((startYear > start) && (endYear < end)) {
artists.push('artist:"' + c + '"');
}
if (artists.length > 10) {
break;
}
}
var query = artists.join(' OR ');
console.log(query);
return query;
}
function searcAndPlay(query) {
var search = new models.Search(query);
currentPlaylist = new models.Playlist();
search.observe(models.EVENT.CHANGE, function() {
if(search.tracks.length) {
// copy tracks to current playlist
$.each(search.tracks, function(index, track){
currentPlaylist.add(models.Track.fromURI(track.uri));
});
player.play(currentPlaylist.get(0), currentPlaylist, 0);
} else {
console.log('search again');
searcAndPlay('classical');
}
});
search.appendNext();
return search;
}
function startMusicByYearRange(startYear, endYear) {
var query = getQueryByYears(startYear, endYear);
// console.log(query);
// var query = "year:" + startYear + "-" + endYear;
console.log(startYear + '-' + endYear)
console.log(query);
var search = searcAndPlay(query);
}
window.startMusicByYearRange = startMusicByYearRange
$(document).ready(function () {
sp = getSpotifyApi(1);
models = sp.require("sp://import/scripts/api/models");
window.player = models.player;
currentPlaylist = new models.Playlist();
// search and play song
startMusicByYearRange(1900, 1910);
// initialize notifier
window.NotifierjsConfig.container.css(window.NotifierjsConfig.position[0], "40px");
window.NotifierjsConfig.container.css(window.NotifierjsConfig.position[1], "20px");
player.observe(models.EVENT.CHANGE, function(event) {
console.log(event);
// $.each(player.track.artists, function(index, artist){
// console.log(artist.name);
// });
// console.log(event.data.playstate)
// event.data.playstate
if (event.data.curtrack) {
Notifier.notify(player.track.name, player.track.artists[0].name, './img/music.png', 4000);
}
});
});
</script>
<script type="text/javascript" src="js/index.js"></script>
<script id="record" type="text/template">
.record
a(href=model.get('url'))
img(src=model.get('url100'))
</script>
</head>
<body>
<div style="width:100%;text-align: center;">
<div id="my-fotorama" style="display: inline-block;"></div>
<div id="my-coverflow" style="display: inline-block;"></div>
</div>
</body>
</html>