Skip to content

Commit

Permalink
Merge commit '46eab2a0d50216ea0e6' into 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
annasob committed Feb 1, 2011
2 parents aca9cc9 + 46eab2a commit 76a36f7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
25 changes: 19 additions & 6 deletions plugins/lastfm/popcorn.lastfm.html
Expand Up @@ -3,41 +3,54 @@
<head>
<title>Popcorn LastFM Plug-in Demo</title>

<!--
ATTENTION
This demo uses an API key obtained for testing the LastFM Popcorn.js
plugin. Please do not use it for other purposes.
-->

<script src="../../popcorn.js"></script>
<script src="popcorn.lastfm.js"></script>
<script>
<script>
document.addEventListener('DOMContentLoaded', function () {
var p = Popcorn('#video')
.volume(0)
.play()
.lastfm({
start: 5, // seconds
end: 15, // seconds
artist: 'yacht',
target: 'lastfmdiv'
target: 'lastfmdiv',
apikey: '30ac38340e8be75f9268727cb4526b3d'
} )
.lastfm({
start: 10, // seconds
end: 20, // seconds
artist: 'the beatles',
target: 'lastfmdiv'
target: 'lastfmdiv',
apikey: '30ac38340e8be75f9268727cb4526b3d'
} )
.lastfm({
start: 15, // seconds
end: 30, // seconds
artist: 'sdfsdfsdfdsddfsdfsdfsddfsf',
target: 'lastfmdiv'
target: 'lastfmdiv',
apikey: '30ac38340e8be75f9268727cb4526b3d'
} )
.lastfm({
start: 20, // seconds
end: 45, // seconds
artist: 'Coldplay',
target: 'lastfmdiv'
target: 'lastfmdiv',
apikey: '30ac38340e8be75f9268727cb4526b3d'
} )
.lastfm({
start: 25, // seconds
end: 40, // seconds
artist: 'yacht',
target: 'lastfmdiv'
target: 'lastfmdiv',
apikey: '30ac38340e8be75f9268727cb4526b3d'
} )
}, false);
</script>
Expand Down
16 changes: 9 additions & 7 deletions plugins/lastfm/popcorn.lastfm.js
Expand Up @@ -6,22 +6,24 @@ var lastFMcallback;
/**
* LastFM popcorn plug-in
* Appends information about a LastFM artist to an element on the page.
* Options parameter will need a start, end, target and artist.
* Options parameter will need a start, end, target, artist and apikey.
* Start is the time that you want this plug-in to execute
* End is the time that you want this plug-in to stop executing
* Artist is the name of who's LastFM information you wish to show
* Target is the id of the document element that the images are
* appended to, this target element must exist on the DOM
* ApiKey is the API key registered with LastFM for use with their API
*
* @param {Object} options
*
*
* Example:
var p = Popcorn('#video')
.lastfm({
start: 5, // seconds, mandatory
end: 15, // seconds, mandatory
artist: 'yacht', // mandatory
target: 'lastfmdiv' // mandatory
start: 5, // seconds, mandatory
end: 15, // seconds, mandatory
artist: 'yacht', // mandatory
target: 'lastfmdiv', // mandatory
apikey: '1234567890abcdef1234567890abcdef' // mandatory
} )
*
*/
Expand Down Expand Up @@ -61,7 +63,7 @@ var lastFMcallback;
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');

script.src = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist="+ options.artist +"&api_key=30ac38340e8be75f9268727cb4526b3d&format=json&callback=lastFMcallback";
script.src = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist="+ options.artist +"&api_key="+options.apikey+"&format=json&callback=lastFMcallback";
script.type = "text/javascript";
head.insertBefore( script, head.firstChild );

Expand Down
14 changes: 11 additions & 3 deletions plugins/lastfm/popcorn.lastfm.unit.js
@@ -1,5 +1,10 @@
test("Popcorn LastFM Plugin", function () {
/*
ATTENTION
This demo uses an API key obtained for testing the LastFM Popcorn.js
plugin. Please do not use it for other purposes.
*/
var popped = Popcorn("#video"),
expects = 8,
count = 0,
Expand Down Expand Up @@ -28,19 +33,22 @@ test("Popcorn LastFM Plugin", function () {
start: 1, // seconds
end: 4, // seconds
artist: 'yacht',
target: 'lastfmdiv'
target: 'lastfmdiv',
apikey: '30ac38340e8be75f9268727cb4526b3d'
} )
.lastfm({
start: 2.5, // seconds
end: 7, // seconds
artist: 'the beatles',
target: 'lastfmdiv'
target: 'lastfmdiv',
apikey: '30ac38340e8be75f9268727cb4526b3d'
} )
.lastfm({
start: 4.5, // seconds
end: 7, // seconds
artist: '',
target: 'lastfmdiv'
target: 'lastfmdiv',
apikey: '30ac38340e8be75f9268727cb4526b3d'
} );

interval = setInterval( function() {
Expand Down

0 comments on commit 76a36f7

Please sign in to comment.