Documentation for this module may be created at Module:Sound/doc

local p = {}

function p.main(frame)
    local args = frame:getParent().args
    local fileName = args[1]
    local size = args[2] or '16px'
    
    if not fileName or fileName == '' then
        return '<span style="color:red; font-weight:bold;">[[Category:Pages with missing sound files]]Error: No file specified</span>'
    end

    local fileUrl = frame:callParserFunction('filepath', fileName)
    
    local container = mw.html.create('span')
        :addClass('sound-button')
        :attr('data-sound-file', fileUrl)
        :attr('title', 'Click to play sound: ' .. fileName)

    container:wikitext(string.format('[[File:Icon-Volume.png|%s|link=]]', size))

    return tostring(container)
end

return p