I want to write an extension for VLC in Lua. I have never worked in Lua, and I can't find any information about this problem.
There is a function to get the current subtitle line directly (which is on the screen) ?
Another problem:
What time of unit will be stored in this variable?
local elapsed_time = vlc.var.get(input, "time")
I couldn't find anything except a two year old post which might be relevant: https://forum.videolan.org/viewtopic.php?f=29&t=102482.
About the get function, according to http://www.videolan.org/developers/vlc/share/lua/README.txt it gets the time property of the input object. You would think it were same as input.time but maybe not.
Related
Is there a way to determine the duration of a video currently set to WKInterfaceInlineMovie? I need to implement a circular progress bar displaying a current progress.
I have a URL of the file initially downloaded from network. It plays well, but I haven't found any way to determine its length (actually, nor questions asking that which is strange).
Of course, I can ask the backend server to send this info, but I'd like to avoid such complications if possible.
OK, it seems I overcame the WKInterfaceInlineMovie API limitation by the help of AVFoundation and CoreMedia.
I create AVAsset object using a movie URL from a shared folder (AVAsset(url:)). Then I get CMTime duration from the AVAsset's duration property (which is a CMTime object).
Actually, I was very surprised to find out that it works. I'm still testing it, because it's too good to be true and I'm expecting to run across some pitfalls. I'll update the answer if anything else's found.
I have searched through the whole internet and didn't find anything useful. Could please anyone suggest how to make a variable explorer in Sublime text 3 like in Spyder?
(Spyder maintainer here) If you want to create a representation of your current namespace (what is shown in the Variable Explorer), you can take a look at how we build it here, specially the value_to_display function, the one really responsible for that.
The viewers (for lists, dicts, Numpy arrays and DataFrames) are implemented in PyQt, and you can find them here.
To bring the value of a variable from a running IPython kernel and pass it to the viewers, we created our own kernel that serializes a value and sends it to Spyder. In Spyder we deserialize it and pass it to the Viewers here (look for the CreateEditor method).
The process is really more complex than this little explanation, but I hope you can get an idea of how it works.
I'm trying to use this database with react-native. First of all, i've found out that it can't retrieve plain objects - i have to retrieve all of the properties in the desired object tree recursively. And it takes about a second per object (~50 numeric props). Slow-ish!
Now, i've somehow imported ~9000 objects in it (each up to 1000 chars including titles). Looks like there is no easy ay to import it, at least it is not described in docs. Anyway, that's acceptable. But now i've found out that my database size (default.realm) is 3.49GB (!). The JSON file, which i was importing is only 6.5mb. I've opened default.realm with Realm Browser and it shows only those ~9000 objects, nothing else. Why so heavy?
Either, i don't understand something very fundamental about this database or it is complete garbage. I really hope i'm wrong. What am I doing wrong?
Please make sure you are not running in chrome debug mode. This is probably why things seem so slow. As far as the file size issue goes, it would be helpful if you posted your code to help figure out why that is happening.
I am making my existing .Net Application Scriptable for non programming users. I added lua, it works like a charm. Then I added debug functionality(pause/continue/step) via debug.sethook. It works also like a charm.
Now I realize that my Application needs edit and continue feature like Visual Studio has it. You pause the execution can edit the code and then continue from your current state with changes applied. This feature is very important to me. I thought this would be easy to do for scripting languages.
Everywhere I read that scripting languages can do this. But even after spending hours of searching I haven't found an Lua implementation yet. It hasn't to be Lua but hot swapping code in Lua would be my first choice.
How can the ability for the user be offered to pause and edit the script and than continue the execution with changes applied?
NOTE: It doesn't have to be Lua every scripting language would be okay
Update
#Schollii
Here is an example:
function doOnX()
if getValue() == "200" then
value = getCalculation()
doSomething() -- many function calls, each can take about 2s
doSomething()
doSomething()
print(value)
doX(value)
end
end
doOnX()
Thank you for your suggestions. This is how it might work:
I will use https://github.com/frabert/NetLua Its a very cool, well written 100% C# Lua Interpreter. It is generating an AST tree first and then directly executing it.
The parser needs to be modified. In Parser.cs public Ast.Block ParseString(string Chunk) there is a parseTree generated first. parseTree.tokens[i].locations are containing the exact position of each token. The Irony.Parsing.ParseTree is then parsed again and is converted to a NetLua.Ast.Block but the location information is missed. I will need to change that so later I will know which Statement is in which line.
Now each Statement from the AST tree is directly executed via EvalBlock. Debug functionality (like I have in my C Binding lua Interpreter DynamicLua via debug.setHook) needs to be added. This can be done in LuaInterpreter.cs internal static LuaArguments EvalBlock(`. Pause/continue/step functions should be no problem. I also can now add current line Highlighting because each statement contains position line information.
When the execution is paused and the code was edited the current LuaContxct is saved. It contains all variables. Also the last Statement with the last execution line is saved.
Now the code String is parsed again to a new AST tree. It gets executed. But all statements are skipped until the saved statement with the line statement is reached. The saved LuaContext is restored and execution can continue with all changes applied.
New variables could be also added after the last executed line, because a new NetLua.Ast.Assignment Statement could just add a new variable to the current LuaContext and everything should just work fine.
Will this work?
I think this is quite challenging and triicky to do right.
Probably the only way you could do that is if you recompile the chunk of code completely. In a function this would mean the whole function regardless of where edit is in function. Then call the function again. Clearly the function must be re-entrant else its side effects (like having incremented a global or upvalue) would have to be undone which isn't possible. If it is not reentrant it will still work just not give expected results (for example if the function increments a global variable by 1 calling it again will result in the global variable having been increased by 2 once the function finally returns).
But finding the lines in the script where the chunknstarts and ends would be tricky if truly generic solution. For specific solution you would have to post specific examples of scripts you want to run and examples of lines you would want to edit. If the whole user script gets recompiled and rerun then this is not a problem, but the side effects is still an issue, examples could help there too.
I wondered if anybody could help me with a technique to address the following problem in Smalltalk. Specifically Cincoms Visualworks.
I would like to code a simple GUI that has three fields and processes them as follows:
The first field inputs a number (5 say).
The second field simply displays twice the first field (so it displays 10 in this example)
Now, the interesting bit... the third field displays a value from a completely different class (let's call it class X). However, the value must be displayed on the GUI whenever that value in the class X changes - it mustn't wait for a key press from an update button. The value in class X could be sourced from (say) the workspace.
I though I could do this via aspect adaptors but I can’t seem to get the 'third field value' to update asynchronously.
Any techniques, hints or tips will be most warmly welcomed - (especially code snippets!!).
Thanks
Kevin
I've sorted this myself. After trying the dependency mechanism (works fine - but simply not needed), looking at announcements (thanks James at Cincom - personal communication) I found that all I needed to do was to simply create a method and send it a message with a parameter (my value) that method then simply updated the value holder (i.e. the aspect of the GUI field) with the "value:" message. The more I look into Smalltalk the more I like it!