The RetroPlayer API is available to JavaScript through the RetroPlayer variable.
This variable is bound to an object that has properties with information from RetroPlayer and methods for controlling RetroPlayer.
appearance |
The current macOS appearance for the window.
The value is a string and the possible values are dependent on the version of macOS but typically values are "NSAppearanceNameAqua" for light mode and "NSAppearanceNameDarkAqua" for dark mode.
|
currentSong |
The song currently being played.
The value is an object with the following properties:
|
playQueue |
A PlayQueue object with the current state of the play queue.
|
position |
The current position in the current song.
The value is the number of seconds into the current song as a a floating point number.
This value is not automatically updated so a custom window implementation should call updateProperties() at a suitable rate.
|
repeat |
The current repeat mode of RetroPlayer.
The value is a string and the possible values are "off" for no repeat, "song" for repeating the current song and "all" for repeating all songs in the play queue.
|
shuffleEnabled |
True will shuffle the play queue and false will restore the play queue to the order that the songs were added.
|
state |
The current playback state.
The value is a string and the possible values are "playing" , "paused" and "stopped" .
|
userDefaults |
The user defaults database for the custom window or visualizer.
It can be observed with addPropertyObserver() but is generally not accessed directly.
Instead getUserDefault() and setUserDefault() is used.
|
addPropertyObserver(propertyName, observer) |
Add an observer to the named property.
The observer must be a function an it will be called with the new property value as a parameter whenever the property value changes.
|
adjustWindowSizeToContent() |
Adjust the window size so that content fits in the window.
The size of the content is found by computing the size of the BODY element.
|
createAnalyser() |
Create an AnalyserNode for doing time and frequency domain analysis of the audio output from RetroPlayer.
It is mostly compatible with the AnalyserNode interface defined by the Web Audio API.
The difference is that it is always connected and only support the methods and properties defined by AnalyserNode and not what it inherits from AudioNode.
|
getElementContentSize(element) |
Get the size of the content of an element.
|
getElementOuterSize(element) |
Get the outer size of an element.
|
getLocalizedString(string, localizedStrings) |
Get a localized string based on the current language.
The caller must provide localized strings as a dictionary object where the language identifier is the key and the value is a new dictionary where the original string is the key and the value is the localized string.
The language identifier is according to ISO 639-1, e.g. "en" for English and "nb" for Norwegian bokmål.
localizedString = RetroPlayer.getLocalizedString("By", { "nb" : { "By" : "Av" } });
|
getUserDefault(key, defaultValue) |
Get the value for a single key in the user defaults database for the custom window or visualizer.
The provided default value will be returned if no value has been set.
|
isKeyWindow() |
Returns true if the custom window or the window the visualizer is in is the current key window.
|
isMainWindow() |
Returns true if the custom window or the window the visualizer is in is the current main window.
|
isPlaying() |
Returns true if a song is playing.
|
pause() |
Pause song playing.
|
play() |
Start playing current song.
|
playNext() |
Start playing the next song in the play queue.
|
playPause () |
Toggle play/pause.
|
playPrevious() |
Start playing the previous song in the play queue.
|
removePropertyObserver(propertyName, observer) |
Remove an observer from the named property.
The observer must be a function that has previously been added as an observer with addPropertyObserver().
|
setMaxPlayQueueSongCount(maxPlayQueueSongCount) |
Set the maximum number of songs to include in the songs property of the playQueue object.
|
setRepeat(repeat) |
Set the repeat property. "off" will disable repeat, "song" will repeat current song and "all" will repeat all songs in the play queue.
|
setShuffleEnabled(shuffleEnabled) |
Set the shuffleEnabled property. true will shuffle the play queue and false will restore the play queue to the order that the songs were added.
|
setUserDefault(key, value) |
Set the value for a single key in the user defaults database for the custom window or visualizer.
|
setUserDefaults(userDefaults) |
Set the user defaults database for the custom window or visualizer.
|
setWindowContentSize(width, height) |
Set the size of the content area of the window.
|
setWindowStyle(windowStyle) |
Set the CSS style to be used for the window.
The style must be a CSSStyleDeclaration object.
This function only affects custom windows and is called automatically when the window has loaded with the computed style for the HTML element.
|
updateProperties(propertyNames) |
Update the value of the named properties.
Observers of properties that changes value will be called.
|