View Issue Details

IDProjectCategoryView StatusLast Update
0019880MMW 5Extensions frameworkpublic2023-03-21 12:58
Reporterpeke Assigned To 
Status assignedResolutionopen 
Target Version5.1.1 
Summary0019880: Player API: PlayabackRules are not available in API
DescriptionAs we mostly switched Output Plugin Settings to Playback rules eg. crossfade, fade in/out, gap it could be useful to open them up to API so that developers and skin designers can customize MM to more advanced (DJ needs) and control playback thru scripts.

That would allow users to create additional controls for specific types and or playback behavior of MM player like older MM4 scripts for Loops, Preview, announcements, ... and be easily added to MM UI/Skins/Toolbars/Actions/...

Initially exposing Current track Playback rule (GET/LET) and temp control of would be more than enough.

Result of that would be that User/Addon dev can easily access and control rules by getting playback properties of playing track object type
Additional InformationNOTE originally asked as MMA feature at
TagsNo tags attached.
Fixed in build



2023-03-17 23:23

developer   ~0071367

image.png (52,926 bytes)   
image.png (52,926 bytes)   


2023-03-20 17:18

developer   ~0071371

Last edited: 2023-03-20 17:22

The API is already there. Peke probably means that the functions to get/set the settings are undocumented, namely:

and currently needs to be sniffed from DevTools > dlg_Options > pnl_PlaybackRules

Or do you mean that there should be an ability to disable crossfade per track (no matter what type the track is)?
i.e. new properties like track.canCrossfade, track.fadeIn, track.fadeOut to override the type settings?


2023-03-20 22:29

developer   ~0071374

Last edited: 2023-03-20 22:48

Something in middle I meant that we expand methods with "getPlaybackRules" which would return "pnl_PlaybackRules" for currently playing track but also like you proposed add new properties track.canCrossfade, track.fadeIn, track.fadeOut, track.canShuffle, track.canAutoDJ and track.remoceSilence to allow Addon developer to control current Player behavior more precisely.

Also would be nice so that Addon Developer can force/override some rules..

i.e. It would make scripts like be more accurate and also allow something like "Play now new episodes from podcast and continue normal playback" or "Disable Crossfade and remove silence for this album" or "Repeat this track 5 times with crossfade" ...

EDIT: any change to playback rules would be only temporary eg. for currently playing track (unless repeat one is enabled where same track would be played) and would reset if , is triggered.


2023-03-20 23:13

developer   ~0071376

Assigned to Michal for a review what to implement for the script's usage..


2023-03-20 23:46

updater   ~0071377

Well, the mentioned Queue List add-on is using some very dirty hacks because of the lack in MM API, but I don't see how this new Playback Rules could change it for better. The add-on is using some tricks with stopAfterCurrentTrack, but that part of code is working fine. However, I mostly have problem with the current playbackState event, because of which I would like too see the whole Player class exposed and implemented in JavaScript, so that it can be analyzed and eventually overridden if needed.


2023-03-21 01:09

developer   ~0071378

I was thinking that exposing PlaybackRule would at least for most part expose how MM player is thinking and how it will end track playback so that you can prevent more easily wrong behavior.

And what about adding forceNext(param track object) method so that along with setting playbackrule you can immediately set force which is next track when playbackState (trackchange) triggers?

Or if I got it correctly on playbackState (trackchange) -> you can set -> ForceNext(Track from queue) -> Set custom playbackrule -> wait next -> playbackState (trackchange)?

Only problem I see is when user triggers event_trackSkipped what would your addon do eg. go to next track in Now Playing or next track in Queue.

Re change for better: Disabling crossfade/gap, AutoDJ, remove silence, fade in/out would give you more freedom to control your queue addon (my 2 cents).


2023-03-21 09:32

updater   ~0071379

Yeah, it would be nice if scripts could have a better control what will be played next, especially in Shuffle mode, but my script would still have problem with the playbackState event, which is a complete mess IMHO, mostly because of your asynchronous execution resulting with random results. You see, there is not any guarantee that you will get the correct result for e.g. player.isPlaying or player.getCurrentTrack or player.trackLengthMS or player.trackPositionMS... when it is checked in the playbackState event handler, especially with the "stop" newState.

Maybe this problem could be solved if the playbackState event returns one more argument behind the newState, which would contain an object of the current track, but I think it will be better if I just open a new issue in Mantis with my comments about it.

Regarding this issue and your description, I didn't use crossfade/gap, AutoDJ, remove silence, fade in/out in MM5 scripts so far, but I though that such things are already implemented. If not, that is a mistake and I am sure that scripters would have benefit of their adding to API.


2023-03-21 12:58

developer   ~0071380

@Peke: your approach is not possible, when playing track is changed it is too late to change fadeIn and crossfade/gap values, as they affect when each track should start to play and how. Also changes in Playlist (like what track will be next) could affect change of this. I'm thinking of adding player event like "crossfadeSettingsUpdated", which will return currently playing track, following track and object with currently active crossfade settings, which will be used when changing current track to the next. And script could listen to this event and apply changes to these settings by some new function. Such settings are evaluated for current situation only and do not change anything in playback rules. I think it is exactly what you want to achieve.