Skip to main content
Inspiring
December 28, 2021
Answered

How to read out time slider position from c++ plugin. Take 2

  • December 28, 2021
  • 1 reply
  • 1760 views

Dear AE fellows,

most of us know that method

in_data ->current_time

 nicely reads out the position of a time slider.

Now the issue. My plugin has  its own win32 window (on top of AE main window) as part of its UI.

A lot of  the functionality of the plugin takes place inside this win32 window.

This win32 window needs the position of the time slider at each moment of the plugin usage. The question is: how can I pass this value to it.

The point is, if I don't change the parameters of my plugin (and I don't), no messages in the EffectMain (like PF_Cmd_RENDER, PF_Cmd_USER_CHANGED_PARAM and so on) are triggered. 

So in_data->current_time never gets updated(!)

Is it at all possible?

 

 

 

 

 

This topic has been closed for replies.
Correct answer shachar carmi

Thanks, for an advice Sachar!

Actually, what I'm trying to implement is the synchronous play of animation in my win32 window and in AE (or Ppro) window. That is needed for the designer preview function.

I sometimes think of  creating a .txt file with the time and update it every 10th of a second and then my win32 window will read the data from the file every 10th of a second and that's it.

Do you think it could be a viable solution? (Here we need to keep in mind that such a synchonization will be switched on by the user just from time to time)


i'd probably go with some shared memory with a mutex instead of a file.

but anyways, idle hook on the plug-in side and a timer on the window side would be the way to go. (imho)

1 reply

Community Expert
December 29, 2021

AEGP_GetItemCurrentTime

Inspiring
December 29, 2021

Thank you, Shachar,

I wrote a simple function:

A_long time_ae(PF_InData * in_data)
{
	AEGP_SuiteHandler suites(in_data->pica_basicP);
	A_Time time;
	AEGP_ItemH myitem;
	suites.ItemSuite8()->AEGP_GetActiveItem(&myitem);
	suites.ItemSuite8()->AEGP_GetItemCurrentTime(myitem, &time);
	return time.value;
}

 However it produces access violation error when hitting  suites.ItemSuite8()->AEGP_GetActiveItem(&myitem); line. Do you know what could be the reason for that?

Community Expert
December 29, 2021

I was thinking about the same lines too.

To pass in_data I do the following.

I declare a global variable:

PF_InData* in_data_glob;

And then, in my EffectMain function I assign: 

in_data_glob = in_data;

I know it looks terrible, but how else could I pass in_data to my win32 LRESULT CALLBACK function?

My win32 window (mainWindow in my notation)  starts as a button of AE UI is pushed.  

So I start it in HandleEvent function, like this:

if (which_hitP->param_index == SKELETON_BUTTON)
{
  std::thread bt(mainWindow, (HINSTANCE)0);
  bt.detach();
}

 

Is there normal way to achieve the result?


yeah... that's the issue.

AE passes a pointer for the in_data to the plugin during a call. when the plug-in returns from that call, AE will relesae the memory holding the in_data, so any access to the same in_data pointer at a later time is guaranteed to fail.

 

furthermore, with the exception of AEGP_CauseIdleRoutinesToBeCalled(), no other callback may be used outside of an AE call span. i.e, your window can't communicate with AE during a window event (unless that window is modal and is ran during the span of an AE call while running on the main UI thread).

so if your window doesn't meet this critirea, you'll need to devise some method of storing a "message" somewhere, and implement some idle hook to check for messages and execute the AE interaction during the idle hook call.