Media Events

Media events for android
platforms: android
$ cordova plugin add com.ironsmile.cordova.mediaevents

Cordova Plugin for Media Events

This cordova plugin gives you the ability to listen to media events from the platform.

Currently implemented events:

  • becomingnoisy - Fired when your media playback is set to become too noisy. For example when the headphones are pulled out.

Events that will be implemented in the future:

  • audiofocusgain - when your application has received the audio focus. You can now use the audio freely.
  • audiofocusloss - when your app has lost the audio focus. Stop audio playback and cleanup all associated resourced.
  • audiofocuslosstransient - When your app has lost the audio focus for very short amount of time. Stop audio playback but you can keep media resourced loaded.
  • audiofocuslosstransientcanduck - You app has lost audio focus but it is acceptable for it to continue playing at lower volume.


  • Android

For the moment I do not think to implement it for any other platform. Pull requests with implementation for other platforms are welcome, though!


  1. cordova plugin add

  2. Edit your platforms/android/AndroidManifest.xml and add <action android:name="" /> into the tag.

Usage Example


function onBecomingNoisy(event) {
    // Do something on becomenoisy event

var app = {

    initialize: function() {

    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);

    onDeviceReady: function() {

    bindPluginEvents: function() {
        window.addEventListener("becomingnoisy", onBecomingNoisy, false);


<script type="text/javascript">


Heavily inspired by the cordova battery status plugin.