1. Home
  2. Docs
  3. Confluence
  4. Confluence User Macros
  5. Audio Control

Audio Control

Summary

This Confluence user macro adds an HTML5 audio control element to your page that can play MP3, OGG and WAV files.

Source Code

#* ============================================================================
* AUDIO CONTROL
*
* This Confluence user macro adds an HTML5 audio control element to your
* page that can play MP3, OGG and WAV files.
*
* Version: 1.0.003
* Date: 2016-11-17
* Author: George Lewe
* Source: https://github.com/glewe/audio-control
* License: GNU LGPLv3
*
* Macro body: None
* Body processing: None
*#

#* ----------------------------------------------------------------------------
* PARAMETERS
*#
## @param File:title=File|type=string|desc=Enter the file name of the audio file. It needs to be attached to the page.|default=myfile.mp3
## @param Format:title=Audio Format|type=enum|enumValues=mp3,mp4,ogg,wav|desc=Select the audio format of the file.|default=mp3
## @param Filename:title=Show File Name|type=boolean|desc=Select to display the file name underneath the control. This might not show in the preview on the right.|default=false

#* ----------------------------------------------------------------------------
* INPUT
*#
#if (!$paramFormat)
#set ($paramFormat="mpeg")
#elseif ($paramFormat=="mp3")
#set ($paramFormat="mpeg")
#end

#set($paramCaption="")
#if ($paramFilename==true)
#set($paramCaption="<p style='margin-top:-4px; font-style:italic'>$paramFile</p>")
#end

#* ----------------------------------------------------------------------------
* OUTPUT
*#
<audio controls><source src="/download/attachments/$content.getIdAsString()/$paramFile" type="audio/$paramFormat">Your browser does not support this HTML5 audio element.</audio>
$paramCaption
Was this article helpful to you? Yes No

Leave a Reply

Your email address will not be published. Required fields are marked *