From: krome Date: Tue, 28 Sep 2010 14:17:10 +0000 (+0200) Subject: Lastfm support added X-Git-Tag: v0.1~26^2~4 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=60fa4589a35f83cc6bacafb861d1be8103dae3fa;p=popcorn-js.git Lastfm support added --- diff --git a/demos/semantic_video/index.html b/demos/semantic_video/index.html index 8b9e05c..cdcb07a 100644 --- a/demos/semantic_video/index.html +++ b/demos/semantic_video/index.html @@ -85,7 +85,7 @@ @@ -118,7 +118,7 @@ }; Popcorn.VideoManager.prototype.loaded = function() { for (var i in this.commandObjects) { - if (this.commandObjects[i].name === 'flickr' || this.commandObjects[i].name === 'footnote' || this.commandObjects[i].name === 'location' || this.commandObjects[i].name === 'twitter' || this.commandObjects[i].name === 'wiki') { + if (this.commandObjects[i].name === 'flickr' || this.commandObjects[i].name === 'footnote' || this.commandObjects[i].name === 'location' || this.commandObjects[i].name === 'twitter' || this.commandObjects[i].name === 'wiki' || this.commandObjects[i].name === 'lastfm') { this.commandObjects[i].extension.image = createImage("images/overlay/" + this.commandObjects[i].name + ".png"); this.commandObjects[i].extension.onIn = function() { this.image.setAttribute('style', "display:inline"); @@ -226,6 +226,11 @@

Google News

+ +
+

Lastfm

+ Collapse +
diff --git a/demos/semantic_video/xml/webMadeMovies.xml b/demos/semantic_video/xml/webMadeMovies.xml index 3ff05ac..0662c60 100644 --- a/demos/semantic_video/xml/webMadeMovies.xml +++ b/demos/semantic_video/xml/webMadeMovies.xml @@ -179,6 +179,10 @@ Celine Celines + + + + diff --git a/popcorn.js b/popcorn.js index d66e033..2328ac9 100644 --- a/popcorn.js +++ b/popcorn.js @@ -626,6 +626,50 @@ }; }; + //////////////////////////////////////////////////////////////////////////// + // Lastfm Command + //////////////////////////////////////////////////////////////////////////// + + Popcorn.LastfmCommand = function(name, params, text, videoManager) { + Popcorn.VideoCommand.call(this, name, params, text, videoManager); + // Setup a default, hidden div to hold the images + var target = document.createElement('div'); + target.setAttribute('id', this.id); + document.getElementById(this.params.target).appendChild(target); + // Div is hidden by default + target.setAttribute('style', 'display:none'); + // This uses jquery + $.getJSON("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist="+ this.params.resourceid +"&api_key=30ac38340e8be75f9268727cb4526b3d&format=json&callback=?", + function(data){ + htmlString = ''; + //console.log(data.artist.image[2]['#text']); + htmlString += '

'+data.artist.name+'

'; + htmlString += ''; + htmlString += '

'+ data.artist.bio.summary +'

'; + htmlString += '

Tags

    '; + jQuery.each(data.artist.tags.tag, function(i,val) { + htmlString += '
  • '+ this.name +'
  • '; + }); + htmlString += '

'; + htmlString += '

Similar

    '; + jQuery.each(data.artist.similar.artist, function(i,val) { + htmlString += '
  • '+ this.name +'
  • '; + }); + htmlString += '

'; + target.innerHTML = htmlString; + } + ); + + this.target = target; + this.onIn = function() { + this.target.setAttribute('style', 'display:inline'); + }; + this.onOut = function() { + this.target.setAttribute('style', 'display:none'); + }; + this.preload = function() {}; // Probably going to need to preload this. + }; + //////////////////////////////////////////////////////////////////////////// // Twitter Command //////////////////////////////////////////////////////////////////////////// @@ -937,6 +981,11 @@ create: function(name, params, text, videoManager) { return new Popcorn.WikiCommand(name, params, text, videoManager); } + }, + lastfm: { + create: function(name, params, text, videoManager) { + return new Popcorn.LastfmCommand(name, params, text, videoManager); + } }, lowerthird: { create: function(name, params, text, videoManager) {