Git Product home page Git Product logo

audiobutton's Introduction

AudioButton

AudioButton is a MediaWiki extension that creates a one-button play/pause toggle for an uploaded audio file.

It is based on https://www.mediawiki.org/wiki/Extension:BoilerPlate.

It makes use of the HTML5 Audio element, without any fallbacks.

Running npm test and composer test will run automated code checks.

If you want to hack on this, whatever you're looking for is probably in extension.json, /resources, or /src.

Volume is optionally controlled with a vol parameter: <ab vol="0.45">foo.mp3</ab>

Preload is optionally controlled with a preload parameter: <ab preload="none">foo.mp3</ab>

The buttons can be styled by modifying MediaWiki:Common.css or MediaWiki:Universal.css. For example:

@import 'https://use.fontawesome.com/releases/v5.4.1/css/all.css';

/* This applies to all buttons */
a.ext-audiobutton {
    font-family: 'Font Awesome 5 Free';
    font-weight: bold;
    /* font-weight: normal; */
}
/* This applies to "play" buttons */
a.ext-audiobutton[ data-state='play' ]:before {
    color: #000;
    content: '\f04b';
    /* content: '\f144'; */
}
/* This applies to "pause" buttons */
a.ext-audiobutton[ data-state='pause' ]:before {
    color: #8b0000;
    content: '\f04c';
    /* content: '\f28b'; */
}
/* This applies to hovered "play" buttons */
a.ext-audiobutton[ data-state='play' ]:hover:before {
    color: #8b0000;
}
/* This applies to hovered "pause" buttons */
a.ext-audiobutton[ data-state='pause' ]:hover:before {
    color: #8b0000;
}
/* This applies to "error" buttons */
a.ext-audiobutton[ data-state='error' ]:before {
    color: #000;
    content: '\f071';
}

For reference, this will override the following default style:

a.ext-audiobutton {
	text-decoration: none;
	&[ data-state='play' ]:before {
		content: '▶️';
	}
	&[ data-state='pause' ]:before {
		content: '⏸️';
	}
	&[ data-state='error' ]:before {
		content: '❓️';
	}
}

audiobutton's People

Contributors

dependabot[bot] avatar elifoster avatar fo-nttax avatar nilsenevoldsen avatar pcjcos avatar r4ndomone avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

audiobutton's Issues

File uses should create a link to the file

On Dota2 we had a bunch of files that were moved without updating the page incorporating them because there were no links generated by their use through this extension. It would be helpful if using a file in this extension added a link from the calling page to the file.

Putting an image before sm2 call causes TypeError

When an image is placed before the sm2/ab call with the left image property, the a.ext-audiobutton gets placed into a separate p tag separate from the audio.ext-audiobutton. button.previousElementSibling in ext.audiobutton.js thus returns null, which causes a TypeError on audio.canPlayType. A solution seems to be placing the sm2 tag inside a span, so I think if the hook itself outputs a span this will be fixed.

Example:

<div class="floatleft"><img alt="Wiki.png" src="..." width="20" height="5" srcset="..."></div>
<audio hidden="" class="ext-audiobutton" data-volume="1.0"><source src="..." type="application/ogg"><a href="...">Link</a></audio>
<p>
	<a class="ext-audiobutton" data-state="play" title="Play/Pause"></a>
</p>

The error in the console:

TypeError: Cannot read property 'canPlayType' of null
    at load.php?debug=false&lang=en&modules=ext.audioButton|ext.reverb.notifications.scripts|oojs-ui-core%2Coojs-ui-widgets&skin=hydradark&version=0ok7bwp:1
    at NodeList.forEach (<anonymous>)
    at load.php?debug=false&lang=en&modules=ext.audioButton|ext.reverb.notifications.scripts|oojs-ui-core%2Coojs-ui-widgets&skin=hydradark&version=0ok7bwp:1
    at load.php?debug=false&lang=en&modules=ext.audioButton|ext.reverb.notifications.scripts|oojs-ui-core%2Coojs-ui-widgets&skin=hydradark&version=0ok7bwp:2
    at mw.loader.implement.css (load.php?debug=false&lang=en&modules=ext.audioButton|ext.reverb.notifications.scripts|oojs-ui-core%2Coojs-ui-widgets&skin=hydradark&version=0ok7bwp:2)
    at runScript (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=hydradark&version=1su7rs5:162)
    at checkCssHandles (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=hydradark&version=1su7rs5:162)
    at Object.<anonymous> (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=hydradark&version=1su7rs5:162)
    at fire (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=hydradark&version=1su7rs5:46)
    at Object.fireWith (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=hydradark&version=1su7rs5:47)
logError @ load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=hydradark&version=1su7rs5:177

Real-world example

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.