Add preview of .mp3, .ogg and .wav links via <audio> tag.

This fixes #745
This commit is contained in:
Simen Graaten 2016-02-19 17:31:10 +01:00
parent 2c9e7c7023
commit b7183fb404

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]
};