-
-
Notifications
You must be signed in to change notification settings - Fork 430
/
Copy pathtemplate.js
98 lines (84 loc) · 2.47 KB
/
template.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
/*
This is a template for how to build a visualization for
AmplitudeJS. The visualization should be modular contain
the methods and variables outlined. You can add any additional
methods or variables inside of the object.
*/
/*
Replace 'VisualizationObjectName' with the proper object
name for your visualization.
*/
function VisualizationObjectName(){
/*
Define the ID of your visualization. This is used to apply
visualizations to songs, playlists, and default. It is a JSON
key so make sure you use `_`
*/
this.id = 'visualization_id';
/*
Define a clean name for your visualization.
*/
this.name = 'Visualization Name';
/*
Initialize the container. This will get set to the element passed in
when you start the visualization.
*/
this.container = '';
/*
Define any settings that your visualization will need. This is JSON so
make sure it's clearly defined and standards are followed. These shoudl be
able to be overwritten by the user when they pass in their preferences.
*/
this.preferences = {
}
/*
Initialize the analyser for the visualization. This will be set when the
visualization is started.
*/
this.analyser = '';
/*
Returns the ID of the visualization. Do not overwrite this, this is necessary
for registering the visualization.
*/
this.getID = function(){
return this.id;
}
/*
Returns the name of the visualization.
*/
this.getName = function(){
return this.name;
}
/*
Merge the user defined preferences with the preferences for the visualization.
*/
this.setPreferences = function( userPreferences ){
for( var key in this.preferences ){
if( userPreferences[ key ] != undefined) {
this.preferences[key] = userPreferences[key];
}
}
}
/*
Start the visualization. Do not over write this. This is how the visualization
gets kicked into gear. The element passed in is the container element where you
will insert canvas' or whatever works.
*/
this.startVisualization = function( element ){
this.analyser = Amplitude.getAnalyser();
this.container = element;
/*
Your code here
*/
}
/*
Stop the visualization. Do not over write this. This gets called when the
visualization is stopped so there's no infinite loops in memory. You should
clear all animation frames and all timed callbacks here.
This will clear the container as well so when the visualization starts again
it can be different than before if needed.
*/
this.stopVisualization = function(){
this.container.innerHTML = '';
}
}