Note: You are currently viewing documentation for Moodle 3.1. Up-to-date documentation for the latest stable version of Moodle is probably available here: MP3 player.

MP3 player

From MoodleDocs
Revision as of 14:51, 26 March 2012 by Mary Cooch (talk | contribs) (added update template)

This page requires updating. Please do so and remove this template when finished.


The multimedia filter embeds MP3 files in a streaming player made with Flash. The big MP3 player is used when an MP3 file is added as a resource. The small player is used when an MP3 file is linked to from within a forum post or another resource or activity using the HTML editor.

MP3 player rates

To ensure that MP3 files are played at the correct rate, sample rates of 11, 22 or 44 kHz should be used. Constant Bit Rate (CBR) files are also recommended over Variable Bit Rate (VBR) files. Please note that sample and bit rates are not the same thing. See the two sections MP3 sample rates and MP3 bit rates below.

MP3 sample rates

Flash Player can produce undesirable results if the MP3 files are not encoded at a sample rate that is not a multiple of 11.025 kHz. In other words, the acceptable sample rates are:

  • 11.025 kHz
  • 22.050 kHz
  • 44.100 kHz

MP3 bit rates

Flash player cannot play MP3 files with a bit rate higher than 128 kbps, which is the default bit rate for most MP3 encoders. For use on the web, lower bit rates are recommended because they download faster and take up less server disk space. Experiment with different bit rates to get the smallest file you can with acceptable sound quality. Common bit rates are:

  • 32 kbps, mono - speech only
  • 40 kbps, mono - music might sound OK
  • 40 kbps, stereo - speech only
  • 48 kbps, mono - some music sounds OK
  • 48 kbps, stereo - speech only
  • 56 kbps, stereo - some music sounds OK
  • 64 kbps, stereo - most music sounds OK


Flash security settings

Security changes in Flash player 7 may result in the MP3 player not playing MP3 files hosted on a remote server. This issue may be resolved by writing a cross-domain policy for the remote server and/or each user changing their global security settings in the Flash player settings manager.

Cross-domain policy

To create a cross-domain policy, save the code below as crossdomain.xml and place the file at the root (public_html or httpdocs) of the remote server.

<?xml version="1.0" encoding="utf-8"?>
<cross-domain-policy>
<!-- Place top level domain name -->
<allow-access-from domain="www.yoursite.com" secure="false"/>
<allow-access-from domain="www.yoursite.com" to-ports="80,443"/>
<allow-http-request-headers-from domain="yoursite.com" headers="*" />
<!-- use if you need access from subdomains. testing/www/staging.domain.com -->
<allow-access-from domain="*.yoursite.com" secure="false" />
<allow-access-from domain="*.yoursite.com" to-ports="80,443" />
<allow-http-request-headers-from domain="*.yoursite.com" headers="*" />
</cross-domain-policy>

Please refer to Macromedia - Developer Center: Security Changes in Macromedia Flash Player 7 for further details.

Global security settings

Please refer to Macromedia - Flash Player Help: Global Privacy Settings Panel.

MP3 player customisation

It is possible to customise the colours of the the MP3 player via CSS included in the theme. For example

.mp3flowplayer_backgroundColor {color: #000000;}

modifies the background colour, see http://flowplayer.org/documentation/skinning/controlbar.html?skin=default for more colour properties, any property that ends with '...Color' can be overridden via CSS.

For accessibility reasons it is not allowed to initiate an automatic playback.

Inserting sounds into questions

See Audio in Moodle

Method to get the Flash player only, and no link to open an external player

  1. In the question text, type "Listen to this sound xxx and say what you heard."
  2. Select xxx
  3. Click on the Insert Web Link button
  4. Give the address of your MP3 file, either a web address or an internal address of a file located in the moodledata directory of your Moodle course.
  5. Toggle HTML source and view the result, something like this: Listen to < a href="http://moodle/file.php/2/audio/trumpet.mp3" >xxx< /a > and say what you heard.
  6. Delete xxx
  7. The result will look something like (2) in screen dump below.
  8. The student can only use the Flash player.
Example of Quiz Question with Sound

Tips and tricks

Temporarily disable the MP3 player

  • You can surround your link with <nolink></nolink> tags to stop any kind of processing including the multimedia filters that create the MP3 player. This may be useful when linking to external MP3 files with characters in their name that Flash cannot understand.
TIP: Be careful with the no link tags or any user written HTML code. The HTML editor may eliminate some of your work if you use the HTML editor in the future. The HTML editor tries to tidy things up for the new user but this can frustrate an experienced user of HTML code.
NOTE: This does not work for something like the following inserted into a page resource.

<nolink><a href="http://theExampleServer.com/file.php/55/mp3_2/mt16/The_file.mp3"> The_file.mp3</a></nolink> , however you can stop the multimedia filter from showing when linking to files by adding ?forcedownload=1 to the end of the link.

See also