forked from sydlawrence/spotify-apps-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
154 lines (132 loc) · 6.72 KB
/
index.html
File metadata and controls
154 lines (132 loc) · 6.72 KB
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
<!DOCTYPE html>
<html>
<head>
<style>
@import url('sp://import/css/eve.css');
@import url('sp://import/css/player.css');
@import url('sp://import/css/ui.css');
@import url('sp://spotify-apps-tutorial/css/main.css');
@import url('sp://spotify-apps-tutorial/css/github.css');
h1, ul {margin:0 0 30px;}
a:hover {color:#83be20;}
</style>
<script src="sp://spotify-apps-tutorial/js/jquery.min.js"></script>
<script src="sp://spotify-apps-tutorial/js/rainbow-custom.min.js"></script>
<script>
$(document).ready(function() {
sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');
var gtrack = sp.require("sp://import/scripts/googletracker");
var tracker = new gtrack.GoogleTracker('UA–xxxxxxx–1');
tabs();
models.application.observe(models.EVENT.ARGUMENTSCHANGED, tabs);
function tabs() {
var args = models.application.arguments;
console.log(args[0]);
$('.section').hide();
$('#'+args[0]).show();
}
});
</script>
</head>
<body>
<div id="wrapper">
<div id="index" class="section">
<h1>Spotify Apps API Tutorials</h1>
<img src="sp://spotify-apps-tutorial/img/spotify-char.png" class="right" />
<h4>Getting started</h4>
<ul>
<li><a href="sp://spotify-apps-tutorial/tutorials/manifest.html">Creating your manifest file</a></li>
<li><a href="spotify:app:spotify-apps-tutorial:tabs">Handling arguments and creating navigational tabs</a></li>
<li>Using the pager element (coming soon)</li>
<li>Dragging and dropping content into an app (coming soon)</li>
<li><a href="sp://spotify-apps-tutorial/tutorials/share.html">Show "Share" popup</a></li>
</ul>
<h4>Playing music</h4>
<ul>
<li><a href="sp://spotify-apps-tutorial/tutorials/Player.html">Play a single song</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/Player+List.html">Play a list of songs</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/current_track.html">Get the currently-playing track</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/click_to_play.html">Create a play/pause button with an HTML element</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/skip_track.html">Skip to the next or previous track</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/Toplist_for_user.html">Get a user's top tracks</a></li>
</ul>
<h4>Searching</h4>
<ul>
<li><a href="sp://spotify-apps-tutorial/tutorials/search.html">Returning all tracks with a given search query</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/artist_top_tracks.html">Get the top 5 most popular tracks from 5 artists</a></li>
</ul>
<h4>Playlists</h4>
<ul>
<li><a href="sp://spotify-apps-tutorial/tutorials/get_songs_from_playlist.html">Get songs from a playlist URL</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/subscribe.html">Subscribe to a playlist</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/playlist_mosaic.html">Showing a playlist mosiac image</a></li>
</ul>
<h4>Interacting with Facebook</h4>
<ul>
<li><a href="sp://spotify-apps-tutorial/tutorials/Facebook_auth.html">Authenticate a user with Facebook</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/Facebook_get_listening_history.html">Get a user's listening history from Facebook</a></li>
</ul>
<h4>Experimental</h4>
<ul>
<li><a href="sp://spotify-apps-tutorial/tutorials/twitter.html">Talking to Twitter</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/last_fm_realtime.html">Last.fm Realtime API</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/polymaps.html">Display a Polymaps object</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/storage.html">Use HTML5's local storage</a></li>
<li><a href="sp://spotify-apps-tutorial/tutorials/template.html">Template</a></li>
</ul>
</div><!-- /index -->
<div id="tabs" class="section">
<ul class="breadcrumb">
<li><a href="spotify:app:spotify-apps-tutorial:index">« Back to main page</a></li>
</ul>
<h1>Handling arguments and creating navigational tabs</h1>
<p class="description">In the manifest.json file, you can update the <code>DefaultTabs</code> property with arguments that corespond to nagivational tab names. In the <code>Application</code> class, when tabs are clicked, the arguments property is updated. In this example, we are simply showing and hiding a <div /> element each time the arguments are updated.</p>
<h3>The manifest.json snippet</h3>
<div id="the-json">
<pre><code data-language="javascript">{
...
"DefaultTabs": [
{
"arguments": "index",
"title": {
"en": "Home"
}
},
{
"arguments": "tabs",
"title": {
"en": "How to use tabs"
}
}
],
...
}</code></pre>
</div>
<h3>The Javascript</h3>
<div id="the-js">
<pre><code data-language="javascript">sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');
tabs(); // See function definition below
/* When a user clicks a tab, the "arguments" property on the
* Application object changes, and the tabs() function fires */
models.application.observe(models.EVENT.ARGUMENTSCHANGED, tabs);
function tabs() {
var args = models.application.arguments;
$('.section').hide(); // Hide all sections
$('#'+args[0]).show(); // Show the current section
}</code></pre>
</div>
<h3>The HTML</h3>
<div id="the-html">
<pre><code data-language="html"><div id="index">
<!-- This content will show up in the "Home" tab -->
</div>
<div id="tabs">
<!-- This content will show up in the "How to use tabs" tab -->
</div></code></pre>
</div>
</div><!-- /tabs -->
</div><!-- /wrapper -->
</body>
</html>