Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-music-controller

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-music-controller

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

cordova-music-remote-controls

Supported platforms

  • Android
  • iOS

Methods

  • Create the media controls:

  function remoteCommandCallback(event,value){
          switch(event){
              case MusicControls.EVENT_PLAY:
                  console.log("######### remoteCommandCallback, event: PLAY");
                  //"value" is zero for this event
                  break;
              case MusicControls.EVENT_PAUSE:
                  console.log("######### remoteCommandCallback, event: PAUSE");
                  //"value" is zero for this event
                  break;
              case MusicControls.EVENT_TOGGLE_PLAY_PAUSE:
                  console.log("######### remoteCommandCallback, event: TOGGLE PLAY PAUSE");
                  //"value" is zero for this event
                  break;
              case MusicControls.EVENT_SKIP_FORWARD:
                  console.log("######### remoteCommandCallback, event: SKIP FW");
                  //"value" is the amout of seconds to skip (the value in info.skipForwardValue)
                  break;
              case MusicControls.EVENT_SKIP_BACKWARD:
                  console.log("######### remoteCommandCallback, event: SKIP BW");
                  //"value" is the amout of seconds to skip (the value in info.skipBackwardValue)
                  break;
          }//switch
      }


var info = {
	title       	: 'Title',		// optional, default : ''
	artist      	: 'Artist',		// optional, default : ''
	artwork	: 'albums/cover.jpg',		// optional, default : nothing
	// cover can be a local path (use fullpath 'file:///storage/emulated/...', or only 'my_image.jpg' if my_image.jpg is in the www folder of your app) or a remote url ('http://...', 'https://...', 'ftp://...')
	isPlaying	: true,			// optional, default : true  [Android]
	dismissable	: true,			// optional, default : false [Android]
	
	// hide previous/next/close buttons:
	hasPrev   	: false,		// show previous button, optional, default: true [Android]
	hasNext   	: false,		// show next button, optional, default: true [Android]
	hasClose  	: true,			// show close button, optional, default: false [Android]

	// Android only, optional
	// text displayed in the status bar when the notification (and the ticker) are updated
	ticker	  : 'Now playing "Time is Running Out"' [Android]
	
	// iOS only
	albumTrackCount   :10, 			// [iOS]
	albumTrackNumber  :1, 			// [iOS]
	playbackDuration  :234.76, 		//in seconds [iOS]
	playbackPosition  :12.5, 		//in seconds, usually this is zero // [iOS]
	playbackRate      :1.0, 		// [iOS]
  
  	/* [iOS] these are used for the skip FW & BW events. It these are missing, the events are not handled and the skip buttons will not be shown in the lock screen.*/
  	skipForwardValue	:30,
  	skipBackwardValue	:30
	
};

var mControl = new MusicControls(info,remoteCommandCallback);

// Register callback for android
mControl.subscribe(remoteCommandCallback);

// Start listening for events
// The plugin will run the events function each time an event is fired
mControl.listen();

  • Destroy the media controller:
mControl.destroy(clearInfo);
  • Methods:
updateIsPlaying(true): Toggle the play/pause notification button [Android]

updateInfo(info): Updates the information shown in the lock screen.

updatePlaybackRate(newPlaybackRate): Updates (only) the playback rate. Uses updateInfo internally [iOS].

updatePlaybackPosition(newPlaybackPosition): Updates (only) the playback position. Uses updateInfo internally [iOS].

FAQs

Package last updated on 17 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc