Page 1 of 1

$10+$10 Lua or c++: Read A->B Loop times at runtime programmatically

Posted: 09 May 2017 07:03
by datafreak
I will award $10 (PayPal etc) to the provider of the solution, and also donate $10 to VideoLAN/VLC and send proof here.
I am not a programmer, sorry, i'm just hacking together a tool to make my life easier, and maybe a couple of other peepz on reddit it's just auto layout of A-B loops saving and restoring, nothing fancy.
- I don't really want to use the Clipper Addon, it's too much for what I need and the interface is just a tad confusing. - I'll only use/mod it, if this method does not work.

Requirement:
I need to pragmatically read the two A->B Loop time variables from running VLC instances on Windows 10, from outside VLC/like when I run an AHK script.

I literally just need the code to read timeA from lua interface and I'm golden but any advice welcome.

Problem is I can't find how to access them from Lua, and not sure if it's even possbile without editing c++ source and compiling etc:

The Private VARIABLES in the SOURCE are:
timeA
timeB

Seems to me they are part of some kind of object called InputManager, which is in the qt4 gui module which I think is an interface.
In the source tree, they are in the following two files (these are code extracts just showing where they occur, with unnecessary code omitted.

vlc-2.2.4\modules\gui\qt4\input_manager.hpp
(near the bottom of this extract)

Code: Select all

public: InputManager( QObject *, intf_thread_t * ); virtual ~InputManager(); void delInput(); bool hasInput() { return p_input /* We have an input */ && !p_input->b_dead /* not dead yet, */ && !p_input->b_eof /* not EOF either */; } int playingStatus(); bool hasAudio(); bool hasVideo() { return hasInput() && b_video; } bool hasVisualisation(); void requestArtUpdate( input_item_t *p_item, bool b_forced ); void setArt( input_item_t *p_item, QString fileUrl ); QString getName() { return oldName; } static const QString decodeArtURL( input_item_t *p_item ); private: intf_thread_t *p_intf; input_thread_t *p_input; vlc_object_t *p_input_vbi; input_item_t *p_item; int i_old_playing_status; QString oldName; QString lastURI; QString artUrl; float f_rate; float f_cache; bool b_video; mtime_t timeA, timeB; void customEvent( QEvent * );
vlc-2.2.4\modules\gui\qt4\input_manager.cpp

Code: Select all

InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) : QObject( parent ), p_intf( _p_intf ) { i_old_playing_status = END_S; oldName = ""; artUrl = ""; p_input = NULL; p_input_vbi = NULL; f_rate = 0.; p_item = NULL; b_video = false; timeA = 0; timeB = 0; f_cache = -1.; /* impossible initial value, different from all */ registerAndCheckEventIds( IMEvent::PositionUpdate, IMEvent::FullscreenControlPlanHide ); registerAndCheckEventIds( PLEvent::PLItemAppended, PLEvent::PLEmpty ); } .. code removed for convenience .. delCallbacks(); i_old_playing_status = END_S; p_item = NULL; oldName = ""; artUrl = ""; b_video = false; timeA = 0; timeB = 0; f_rate = 0. ; .. code rermoved for convenience ... void InputManager::setAtoB() { if( !timeA ) { timeA = var_GetTime( THEMIM->getInput(), "time" ); } else if( !timeB ) { timeB = var_GetTime( THEMIM->getInput(), "time" ); var_SetTime( THEMIM->getInput(), "time" , timeA ); CONNECT( this, positionUpdated( float, int64_t, int ), this, AtoBLoop( float, int64_t, int ) ); } else { timeA = 0; timeB = 0; disconnect( this, SIGNAL( positionUpdated( float, int64_t, int ) ), this, SLOT( AtoBLoop( float, int64_t, int ) ) ); } emit AtoBchanged( (timeA != 0 ), (timeB != 0 ) ); } /* Function called regularly when in an AtoB loop */ void InputManager::AtoBLoop( float, int64_t i_time, int ) { if( timeB && i_time >= timeB ) var_SetTime( THEMIM->getInput(), "time" , timeA );
My gueses at possible solutions
  • Provide the required code to read the variables from the Lua interface - I should be able to do the rest.
  • (Mod the c++/source & compile) to expose the values to Lua or otherwise programmatically get the values out to somewhere at runtime. Values can be 0 or time values.
  • Mod the c++ source to put the A/B time values in the VLC window title or somewhere in running meta data accessible in Lua - I can happily extrapolate at runtime as i'll be using cmdow https://ritchielawrence.github.io/cmdow/ already which can also list full window titles.
  • .. any other ideas..
I'm predicting that the vars need globalising in the c++ source which should make them accessible from Lua once compiled but not that I know how to do that so, up to the Pro's, I wonder if anyone will even reply to this lol, I've tried to format it nicely.

In VLC main (qt4 gui) interface If you cannot see the A->B Loop Button you have to click View->Advanced Controls and it comes up on an extra bar controls, near snapshot i think, also shift+L is the hotkey for it, it adds A then B then clears.

My Top tips of the day: Try Ditto (a windows, clipboard manager, quite updated, nice, fast/lightweight, very functional, http://ditto-cp.sourceforge.net) it's amazing, I could not live without it now, saves SO MUCH TIME. It's really good. You just gotta get used to using it often then it's second nature and tweak the settings for you, maybe increase the retention time, also it's nice how it removes formatting/RTF with ctrl+enter, multi pastes, loads of cool things.

Also LastPass, Mobile is now free in case you did not know (I only found out recently but been long time on Free).

Thanks for your time!!

Re: $10+$10 Lua or c++: Read A->B Loop times at runtime programmatically

Posted: 09 May 2017 23:22
by mederi
You can file your feature request at https://trac.videolan.org/vlc

Re: $10+$10 Lua or c++: Read A->B Loop times at runtime programmatically

Posted: 09 May 2017 23:24
by datafreak
You can file your feature request at https://trac.videolan.org/vlc
Oh good idea, perhaps they will be able to add it in.

Thanks!

Re: $10+$10 Lua or c++: Read A->B Loop times at runtime programmatically

Posted: 13 May 2017 11:56
by Etoh
My understanding is that the TimeA/TimeB feature is QT-specific, and that as a result of this the variables are not stored within "input" and are therefore not accessible to Lua scripts. As you suggest, this would mean that VLC code would need to be modified to allow for the variables to be exposed to Lua scripts. However, you could have other inputs to allow A and B to be set, either within VLC or in your third-party application.

Re: $10+$10 Lua or c++: Read A->B Loop times at runtime programmatically

Posted: 14 May 2017 12:34
by datafreak
My understanding is that the TimeA/TimeB feature is QT-specific, and that as a result of this the variables are not stored within "input" and are therefore not accessible to Lua scripts. As you suggest, this would mean that VLC code would need to be modified to allow for the variables to be exposed to Lua scripts. However, you could have other inputs to allow A and B to be set, either within VLC or in your third-party application.
OK thanks for making that all clear Etoh.
I think now I need to expose the variables from c++ or just use the Addon.
Many thanks.