PoziTone module SDK
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.
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>
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.
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' );
- YouTube embedded player | external PoziTone module
- SoundCloud Widget | external PoziTone module
- Sovyatnik | external PoziTone module
This document is a work-in-progress and will be updated with more instructions soon...