Player and expansion communication......
-
So I have a player, with a list of libraries/instruments that it knows about, I want to be able to load an instrument - but retain this list AND ITS STATE
Now @Christoph-Hart tells me:
"and a common shared left tab is not the hardest thing to implement"- which is correct - but one that share s open/closed state information is probably quite a lot harder.....
So the only way I can think of communicating this "state information" between player and instrument is to use a classic file-as-postbox approach ....but but but...
I have no way of assuring that the write to postbox is complete before opening the requested instrument. Or do I?
There's no callback for write-to-file-complete, and the write is async I think so it will or wont have happened by the time the expansion is reading the file..so no gtee's there either.
Anyone put me right or have a better idea on this?
-
@Lindon What information does the "state" include?
-
@David-Healey state is simply "open" or "closed" (0 or 1) for every library (which has categories in it) and Categories(which have instruments in them)
State needs to be transferable BOTH ways so we start with all libs closed....
In the player we open LibA, open CatA and load InstrumentAA
InstrumentAA opens and displays the LibPanel with all libs closed except LibA, and within that CatA is also open...
In instrumentAA we close LibA and Open LibB, then we close InstrumentAA,
The player opens with all libs closed except LibB
-
@Lindon How does it need to work between multiple instances of the plugin?
-
@David-Healey --- havent even considered that, any way you want.
-
@Lindon said in Player and expansion communication......:
@David-Healey state is simply "open" or "closed" (0 or 1) for every library (which has categories in it) and Categories(which have instruments in them)
State needs to be transferable BOTH ways so we start with all libs closed....
In the player we open LibA, open CatA and load InstrumentAA
InstrumentAA opens and displays the LibPanel with all libs closed except LibA, and within that CatA is also open...
In instrumentAA we close LibA and Open LibB, then we close InstrumentAA,
The player opens with all libs closed except LibB
The problem(well theres a truck load of problems..) here is I can see how I can save state (in some file) and read it on plugin(player) load...and as soon as the user requests a load of an instrument we write the current states to the file.
The instrument reads this state file on load and sets the display correctly. On instrument unload (so the instrument is unloading itself) the instrument saves the new state(assuming its changed) and unloads itself.....
..but I dont know how the player now reads this new state file in any efficient manner- meaning not running a timer every 0.5 seconds to re-read the state file......???
The player never knows the instrument is now unloaded does it? Or can it tell from
ExpansionHandler.getCurrentExpansion() if it == "" then whatever it loaded is now unloaded... ???
Or how is the player itself loading/unloading whilst a Full Instrument is in play? I guess I need to know the mechanics of player/instrument load/unload ....do we execute init again? ...@Christoph-Hart !!!
-
@Lindon If you set the current expansion to "" that will trigger the unload action, so you can respond to that. I'm not sure if that reruns the player's
on initbut you could test.I think a timer and polling on the message thread is the way to go, the timer won't run when the interface is minimised anyway.
-
@David-Healey said in Player and expansion communication......:
@Lindon If you set the current expansion to "" that will trigger the unload action, so you can respond to that. I'm not sure if that reruns the player's
on initbut you could test.I think a timer and polling on the message thread is the way to go, the timer won't run when the interface is minimised anyway.
Yeah its the expansion that will be setting the current expansion to "" - so I'm not sure how the player responds to that....I cant see a expansion changed callback or listener...
-
@Lindon said in Player and expansion communication......:
cant see a expansion changed callback
ExpansionHandler.setExpansionCallback()Not sure if it works in this scenario the way you need but give it a try.