-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaylist.js
115 lines (98 loc) · 2.61 KB
/
playlist.js
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
var currentTrack = 0;
var tracks = new Array();
function setCurrentTrack(id) {
currentTrack = id;
}
function addTrack(para)
{
console.log("addTrack");
var where = tracks.length;
tracks[where] = new Object();
tracks[where] = para;
console.log(where);
}
function getTrack(id)
{
return tracks[id];
}
function nextTrack() {
currentTrack++;
}
function lastTrack() {
currentTrack--;
}
function jumpTo (id) {
currentTrack = id;
return tracks[currentTrack];
}
exports.addTrack = addTrack;
exports.setCurrentTrack = setCurrentTrack;
exports.getTrack = getTrack;
exports.nextTrack = nextTrack;
exports.jumpTo = jumpTo;
exports.currentTrack = currentTrack;
exports.tracks = tracks;
exports.lastTrack = lastTrack;
/*
FUNKTION ADDLINK :
PARAMETER URL
Fügt bei entsprechenden Link den Track zur Playlist
*/
/*function addLink(link) {
var jetzt = new Date();
var i = tracks.length;
console.log("Addlink aufgerufen: i = " + i);
console.log("Addlink aufgerufen: link = " + link);
tracks[i] = new Object();
tracks[i]["url"] = link;
tracks[i]["time"] = jetzt.getTime();;
tracks[i]["fromHostname"] = $.url(link).attr('host');
tracks[i]["id"] = $.url(link).param("v");
console.log($.url(link).param("v"))
// YOUTUBE
if(tracks[i].fromHostname == "www.youtube.com" || tracks[i].fromHostname == "www.youtube.de" )
{
$.ajax({
url : 'https://gdata.youtube.com/feeds/api/videos/' + tracks[i].id + '?v=2&alt=jsonc',
dataType: 'jsonp',
success: function(response) {
youtubeFeedCallback(response);
}
});
function youtubeFeedCallback(response) {
console.log("Jetzt kommt die response");
console.log(response);
tracks[i]["title"] = response.data.title;
that.updatePlaylist();
console.log(tracks[i]);
}
}
// SOUNDCLOUD
else if(tracks[i].fromHostname == "soundcloud.com" || "www.soundcloud.com")
{
var track_url = tracks[i].url;
SC.get('/resolve', { url: track_url }, function(response) {
tracks[i]["title"] = response.title;
tracks[i]["id"] = response.id;
that.updatePlaylist();
console.log(tracks[i]);
});
}
else if (tracks[i]["fromHostname"] == "myvideo.com" || tracks[i].fromHostname == "myvideo.de")
console.log("Myvideo ist noch nicht funktionsfähig");
else
console.log("URL unbekannt");
}
*/
/*
function updatePlaylist() {
var string = "<h3>Playlist</h3><ul>";
for(var i = 0; i < tracks.length; i++)
{
if(i == currentTrack)
string += "<li class='current'><a href='javascript:changeTrack(" + i +");'>"+tracks[i].title+"</a></li>";
else
string += "<li><a href='javascript:changeTrack(" + i +");'>"+tracks[i].title+"</a></li>";
}
string += "</ul>";
}*/