Skip to content

PoziTone module SDK lets you create an external PoziTone module

License

Notifications You must be signed in to change notification settings

PoziWorld/PoziTone-module-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PoziTone module SDKPoziTone

This SDK lets you create an external PoziTone module – a standalone extension which will provide PoziTone features to not yet supported online media players.

Such external PoziTone module gets published separately from PoziTone allowing you to get a proper credit for your work.


Table of contents

Include SDK file

PoziTone module SDK is written in ES5 and doesn't have any dependencies.

Include the SDK JavaScript file before any other JavaScript files.

// Remember to replace "/path/to/"
<script src="/path/to/pozitone-module-sdk.js"></script>

(back to table of contents)

Initialize SDK

Before your module can make any calls to the SDK, you need to initialize the SDK and provide an appropriate PoziTone “edition” name.

There are four PoziTone editions available:

  • alpha – may contain new features that are unstable and need to be properly tested before being released to everybody.
  • beta – may contain new features that have been tested, but need more testing before being released to everybody.
  • stable – the version of PoziTone that gets released to everybody and shouldn't have major issues.
  • test – downloaded from the source and loaded unpacked in Developer mode. (Sometimes extension ID of such edition doesn't match the one hardcoded in the SDK. The fix is on the way.)
// Specify PoziTone edition you will be connecting to: 'alpha', 'beta', 'stable', or 'test'.
pozitoneModule.sdk.init( 'stable' );

This is done only once per component/class/script/page.

(back to table of contents)


Connect with PoziTone

Before your module is able to utilize any PoziTone features, you need to connect it with PoziTone.

/**
 * Send request to PoziTone to connect the module.
 *
 * @type    method
 * @param   objSettings
 *            Module settings.
 * @param   funcSuccessCallback
 *            Optional. Function to run on success.
 * @param   funcErrorCallback
 *            Optional. Function to run on error.
 * @return  void
 **/

pozitoneModule.sdk.connectModule( objSettings, funcSuccessCallback, funcErrorCallback );

where

const objSettings = {
  objSettings_com_example : { // Replace com_example (for example, com_github if your module is for github.com)
      strName : 'Example'
    , boolIsEnabled : true
    , boolShowNotificationLogo : true
    , strNotificationLogo : 'site' // Other options: 'station'
    , strNotificationTitleFormat : 'short' // Optional. Other options: 'long', 'noStationInfo'
    , arrAvailableNotificationTitleFormats : [ // Optional. If multiple are available
          'short'
        , 'long'
        , 'noStationInfo'
      ]
    , arrAvailableNotificationButtons : [ // Choose only the applicable ones
          'add'
        , 'addAuth'
        , 'favorite'
        , 'favoriteAuth'
        , 'next'
        , 'nextAuth'
        , 'previous'
        , 'previousAuth'
        , 'playStop'
        , 'muteUnmute'
        , 'volumeUp'
        , 'volumeDown'
      ]
    , arrActiveNotificationButtons : [ // Two active buttons maximum. Any from the available ones
          'playStop'
        , 'muteUnmute'
      ]
    , boolShowNotificationWhenStopped : false // Optional
    , boolShowNotificationWhenMuted : false
    , boolShowNotificationWhenNoTrackInfo : false // Optional
    , boolUseGeneralVolumeDelta : true // Optional
    , intVolumeDelta : 10 // Optional
    , strRegex : '(http:\/\/|https:\/\/)example.com\/.*'
  }
};

Once connected, you can offer user to open the module settings subpage/section within PoziTone Options page.

// Replace com_example with the appropriate name
pozitoneModule.sdk.openModuleSettings( 'com_example' );

(back to table of contents)


Modules utilizing this SDK

(back to table of contents)


To be continued

This document is a work-in-progress and will be updated with more instructions soon...

(back to table of contents)

About

PoziTone module SDK lets you create an external PoziTone module

Resources

License

Stars

Watchers

Forks

Packages

No packages published