cordova-plugin-media-extended

Cordova plugin Media, exdended to change setMediaStreamType constant on Android. Can play sound as System sound, as Ring, as Music etc.

Usage no npm install needed!

<script type="module">
  import cordovaPluginMediaExtended from 'https://cdn.skypack.dev/cordova-plugin-media-extended';
</script>

README

cordova-plugin-media-with-setAudioStreamType

Fork of Media plugin with adding ability to change media play type: Ring, Music, Notification, system

This plugin provides the ability to record and play back audio files on a device.

Supported Platforms

  • Android
  • Browser

Additional static methods available on Android:

  • Media.mute_microphone(true); //mic muted
  • Media.mute_microphone(false); //mic not muted
  • Media.mute_stream(streamType);
  • Media.mute_stream("music"); // music stream muted // new same call unmute stream

Stream Types avialable

  • notification
  • alarm(The audio stream for alarms)
  • dtmf(The audio stream for DTMF Tones)
  • music(The audio stream for music playback
  • notification (The audio stream for notifications)
  • ring(The audio stream for the phone ring)
  • system(The audio stream for system sounds)
  • voice_call

Example

var incomingCallSound = new Media(src, mediaSuccess, [mediaErrorCB], [mediaStatusCB], streamType);  
//or use static method before object created
Media.setStreamType ="music";

Parameters

  • src: A URI containing the audio content. (DOMString)

  • mediaSuccess: (Optional) The callback that executes after a Media object has completed the current play, record, or stop action. (Function)

  • mediaError: (Optional) The callback that executes if an error occurs. (Function)

  • mediaStatus: (Optional) The callback that executes to indicate status changes. (Function)

  • streamType: (Optional) StreamType setting. (String)

// Avialable stream types:
//alarm	(The audio stream for alarms)
//dtmf	(The audio stream for DTMF Tones)
//music	(The audio stream for music playback
//notification (The audio stream for notifications)
//ring	(The audio stream for the phone ring)
//system	(The audio stream for system sounds)
//voice_call

//OPTION 1:  You should call setStreamType before create an media object
Media.setStreamType("music");
var my_media = new Media('cdvfile://localhost/temporary/recording.mp3', ...);
//OPTION 2: You can set streamType by type paramert of constructor 
var incomingCallSound = new Media(src, mediaSuccess, [mediaErrorCB], [mediaStatusCB], streamType);  

install

PhoneGap build or Cordova cli: (add to config.xml)

all others features one by one forked from cordova-plugin-media 2.2.1