Merge pull request #746 from simeng/master

Add preview of .mp3, .ogg and .wav links via <audio> tag.
This commit is contained in:
Tor Hveem 2016-02-19 18:04:56 +01:00
commit c706c93e43
1 changed files with 19 additions and 1 deletions

View File

@ -313,6 +313,24 @@ plugins.factory('userPlugins', function() {
}
});
/*
* audio Preview
*/
var audioPlugin = new UrlPlugin('audio', function(url) {
if (url.match(/\.(mp3|ogg|wav)\b/i)) {
return function() {
var element = this.getElement();
var aelement = angular.element('<audio controls></audio>')
.addClass('embed')
.attr('width', '560')
.append(angular.element('<source></source>')
.attr('src', url));
element.innerHTML = aelement.prop('outerHTML');
};
}
});
/*
* mp4 video Preview
*/
@ -504,7 +522,7 @@ plugins.factory('userPlugins', function() {
});
return {
plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, giphyPlugin, tweetPlugin, vinePlugin]
plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, giphyPlugin, tweetPlugin, vinePlugin]
};