-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path8tracks.php
131 lines (122 loc) · 4.82 KB
/
8tracks.php
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
<!DOCTYPE html>
<html lang="en">
<head>
<?php
include("res/php/auth.php");
include("res/php/loadfunc.php");
include("res/php/links.php");
?>
<script type="text/javascript">
var lfmbase = "http://ws.audioscrobbler.com/2.0/";
var lfmkey = "&api_key=b15a0b92b58b210280fa88c5ae3bd038";
var etbase = "http://8tracks.com";
var etkey = "?api_key=efaea88b3f74c64c06351f6e76674f65bcc23ea0&api_version=2";
function listen() {
var myplayer = document.getElementById('player');
var timepast = myplayer.currentTime;
var duration = myplayer.duration;
var width = String(100*(timepast / duration));
document.getElementById('time').setAttribute("style", "width:" + width + "%");
if (timepast <= 0) {
var url = document.getElementById("src").innerHTML;
myplayer.setAttribute("src", url);
myplayer.play();
}
if (30 < timepast && timepast < 31) {
var url = document.getElementById('back').innerHTML;
document.getElementById('report').innerHTML = "<?= report_back(" + url + ");?>";
document.getElementById('sent').setAttribute("class", "muted");
}
window.setTimeout (function() { listen(); }, 1000);
}
function toggleMusic() {
var player = document.getElementById('player');
var button = document.getElementById('control');
if (player.paused) { player.play(); button.setAttribute("class", "icon-pause icon-white"); }
else { player.pause(); button.setAttribute("class", "icon-play icon-white"); }
}
// Autocomplete BEGIN
$(function() {
$("input#tag").autocomplete({
source: function(request, response) {
$.ajax({
url: etbase + "/tags.jsonp" + etkey + "&q=" + request.term,
dataType: "jsonp",
success: function(data) {
response($.map(data.tags, function(item) {
return { label: item.name, value: item.name }
}));
}
});
},
minLength: 2,
open: function() { $(this).addClass( "ui-autocomplete-loading" ); },
close: function() { $(this).removeClass( "ui-autocomplete-loading" ); }
});
});
// Autocomplete END
</script>
<style type="text/css">
.control-conatiner { height: 20px; width: 20px; padding: 0px; }
#control { margin: 0px; }
.data { display: none; }
</style>
</head>
<body onload="listen()">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="brand" href="./index.php">JamWalkr</a>
<ul class="nav">
<li><a href="./index.php"><i class="icon-home icon-white"></i></a></li>
<li><a href="./ajax.php"><i class="icon-music icon-white"></i></a></li>
<li class="active"><a href="./8tracks.php"><i class="icon-headphones icon-white"></i></a></li>
<li><a href="./map.php"><i class="icon-map-marker icon-white"></i></a></li>
</ul>
</div>
</div>
</div>
<div class="container-fluid" style="margin-top: 50px;">
<div class="row-fluid">
<div class="span12">
<h1>8Tracks API</h1>
<?php if (!isset($_REQUEST["tag"]) || ($_REQUEST["tag"] == "")) { ?>
<form class="form-search" method="post" action="8tracks.php">
<div class="input-append">
<input type="text" class="input-medium search-query" name="tag" id="tag" placeholder="mood, genre, or artist" autofocus="autofocus" />
<button type="submit" class="btn">Search</button>
</div>
</form>
<?php } else {
$tags = urlencode($_REQUEST["tag"]);
if ((($mid = most_pop_mix ($tags)) != false) && (($ptok = play_token ()) != false)) {
$purl = $etbase."/sets/".$ptok."/play.xml".$etkey."&mix_id=".$mid;
$song = play_track ($mid, $ptok, $purl);
?>
<p class="lead">You're listening to the "<?=$_REQUEST["tag"];?>" tag.</p>
<div class="data">
<span id="music"></span>
<span id="src"><?=$song['url'];?></span>
<span id="back"><?=$song['back'];?></span>
<span id="next"><?=$song['next'];?></span>
<span id="report"></span>
</div>
<video id="player" class="data"></video>
<div>
<button class="btn btn-jam control-conatiner pull-left">
<i onclick="toggleMusic()" id="control" class="icon-pause icon-white"></i>
</button>
<div class="progress progress-jam progress-striped active">
<div class="bar" id="time"></div>
</div>
</div>
<div><?= display_mix_info ($mid);?></div>
<ul id="sent">
<li><strong><?=$song['artist']?></strong> <?=$song['title']?></li>
</ul>
<?php } } ?>
</div>
</div>
</div>
</body>
</html>