Skip to content
Snippets Groups Projects
Commit 5122bdca authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Display player for audio files

parent 13779cc1
No related branches found
No related tags found
No related merge requests found
function drawBuffer( width, height, context, data ) {
var step = Math.ceil( data.length / width );
var amp = height / 2;
context.fillStyle = "silver";
context.clearRect(0,0,width,height);
for(var i=0; i < width; i++){
var min = 1.0;
var max = -1.0;
for (j=0; j<step; j++) {
var datum = data[(i*step)+j];
if (datum < min)
min = datum;
if (datum > max)
max = datum;
}
context.fillRect(i,(1+min)*amp,1,Math.max(1,(max-min)*amp));
}
}
......@@ -4,6 +4,9 @@ Template.oembedBaseWidget.helpers
if this.headers?.contentType?.match(/image\/.*/)?
return 'oembedImageWidget'
if this.headers?.contentType?.match(/audio\/.*/)?
return 'oembedAudioWidget'
if this.parsedUrl?.host is 'www.youtube.com' and this.meta?.twitterPlayer?
return 'oembedYoutubeWidget'
......
<template name="oembedAudioWidget">
<a href="{{url}}" target="_blank">
{{#if parsedUrl}}
<blockquote>
<audio controls>
<source src="{{url}}" type="{{headers.contentType}}">
Your browser does not support the audio element.
</audio>
</blockquote>
{{/if}}
</a>
</template>
......@@ -2,7 +2,7 @@
<a href="{{url}}" target="_blank">
{{#if parsedUrl}}
<blockquote>
<img src="{{url}}" height="200" style="max-width: 100%" />
<img src="{{url}}" height="200" style="max-width: 100%" />
</blockquote>
{{/if}}
</a>
......
......@@ -19,6 +19,8 @@ Package.onUse(function(api) {
api.addFiles('client/oembedImageWidget.html', 'client');
api.addFiles('client/oembedAudioWidget.html', 'client');
api.addFiles('client/oembedYoutubeWidget.html', 'client');
api.addFiles('client/oembedUrlWidget.html', 'client');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment