New plugin: spotify
This commit is contained in:
parent
45a0d0cd21
commit
5923093071
1 changed files with 24 additions and 1 deletions
|
@ -127,6 +127,29 @@ plugins.factory('userPlugins', function() {
|
|||
|
||||
var urlRegexp = RegExp(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/);
|
||||
|
||||
/*
|
||||
* Spotify Embedded Player
|
||||
*
|
||||
* See: https://developer.spotify.com/technologies/widgets/spotify-play-button/
|
||||
*
|
||||
*/
|
||||
|
||||
var spotifyPlugin = new Plugin(function(message) {
|
||||
var addMatch = function(match) {
|
||||
var ret = '';
|
||||
for(i in match) {
|
||||
var id = match[i].substr(match[i].length-22, match[i].length);
|
||||
ret += '<iframe src="//embed.spotify.com/?uri=spotify:track:'+id+'" width="300" height="80" frameborder="0" allowtransparency="true"></iframe>';
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
var match = message.match(/spotify:track:([a-zA-Z-0-9]{22})/g);
|
||||
var ret = addMatch(match);
|
||||
ret += addMatch(message.match(/open.spotify.com\/track\/([a-zA-Z-0-9]{22})/g));
|
||||
return ret;
|
||||
});
|
||||
spotifyPlugin.name = 'Spotify track'
|
||||
|
||||
/*
|
||||
* YouTube Embedded Player
|
||||
*
|
||||
|
@ -172,6 +195,6 @@ plugins.factory('userPlugins', function() {
|
|||
imagePlugin.name = 'image';
|
||||
|
||||
return {
|
||||
plugins: [youtubePlugin, imagePlugin]
|
||||
plugins: [youtubePlugin, imagePlugin, spotifyPlugin]
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue