Can you control an already open instance of VLC with the VLC python module? - vlc

For my program I need to control an already open instance of VLC (I just want to increase/decrease the volume and make it pause), but I do not know if that is even possible as it seems you have to create instances to control them. Just wondering if anyone knew a way to do this? The following doesn't work presumably because VLC is playing before the media_player instance is created.
media_player = vlc.MediaPlayer()
def upvol():
value = media_player.audio_get_volume()
value = value + 5
media_player.audio_set_volume(value)
def downvol():
value = media_player.audio_get_volume()
value = value - 5
media_player.audio_set_volume(value)
Additionally, is there a way to make attempt to open any arbitrary file type?

Related

How to use variables in LUA 5.1 Touchosc

I'm trying, to wrap my head around Touchosc and script based on LUA 5.1.
I have a number of labels, called song0, song1, song2, and so on. I'm trying to set different values in these, using
local text = 'Smoke On The Water'
for i = 1, 2 do
self.children.pager1.children.main.children.song[i].values.text = text
end
but that gives me an error.
:-) I do need help.
Finn
Since you haven't provided the actual error, it's difficult to say what the problem is, but if I have to venture a guess, then try replacing ...children.song[i].values... with ...children["song"..i].values.... Since there is no table song, you just need to generate dynamic field names.

UIPrintInteractionController set minimum number of copies

I'd like to know if there's a way to set a minimum number of copies to be printed via code, because I need a document to be printed by duplicate.
I read the documentation on Apple developers page but I couldn't find anything.
I know you can set the number of copies from the printer dialog, but I need the minimum to be 2 by default.
Thanks in advance!
EDIT:
I tried this and it didn't work for me, at least in Xamarin.
There is nothing exposed via UIPrintInteractionController or its delegates that allows you to change/override the number of copies.
The way I approach this is to write my own UIController that defines the properties that the user is allowed to change and then use UIPrintInteractionController.PrintToPrinter to directly print the content.
Another approach is to disable the number of copies display:
UIPrintInteractionController.ShowsNumberOfCopies = false;
And then provide a two element array to PrintingItems vs. PrintingItem that just contains two copies of your print object.
Another approach just allow the user to select the printer via UIPrinterPickerController, save the UIPrinter to skip it in the future and then call PrintToPrinter twice.

Cannot Access Text In A Roblox TextBox

Whenever I try to do this set of code in robloxian lua, I can't access the textbox. This code is suppost to do this, but I think that its accessing the property of the text inside the textbox instead. Here is a somewhat representative of the code that I am using. So, lets say that Bob wants to talk to John. I would write it like this.
game.StarterGui.ScreenGui.Frame.JohnsSpeech.Text = game.StarterGui.ScreenGui.Frame.JohnsUserSetText.Text
Now, JohnsUserSetText is the textbox, and JohnsSpeech is the speech. But when I try to do this, it doesn't work. It just says whatever the text is in the properties. Any help would be appreciated. Thanks! And have a great rest of your day!
Supposed to do what?
.Text is a property of a textbox or anything similar
NOTE: You are changing a starter gui, which means anyone using that current gui won't get the updated one until they die and respawn. If you want to update the one in their GUI access it through Game.Players.playernamehere.PlayerGui
StarterGui is what the game imports into a player when it reloads everything AKA: respawning or joining
if you need tips on updating each players Gui tell me and I can give some examples
Much as M. Ziegenhorn is saying, your issue is that you're referring to the StarterGui, not the PlayerGui.
The StarterGui is the container containing the default GUIs to be given out to the player upon spawn, while PlayerGui (game.Players.Ravenshield.PlayerGui, for instance) is where the GUIs are stored for each player.
The PlayerGui can only be accessed through a LocalScript.
The easiest way to access your PlayerGui is obviously to just place the LocalScript inside the ScreenGui you're using.
Otherwise, you can also access it easily by doing game.Players.LocalPlayer.PlayerGui
If I were to put my LocalScript directly in the ScreenGui we're using, it could look like this:
local TextBox = script.Parent.TextBox
local SpeechLabel = script.Parent.SpeechLabel
SpeechLabel.Text = TextBox.Text
However, you probably want to add text whenever they write it into the TextBox. Then we need to take a look at the documentation for ROBLOX, and specifically the TextBox Object.
If you scroll down to the Events, you can take a look at the TextBox.Changed event. This will fire everytime a property of the TextBox changes.
We could also use TextBox.FocusLost, which fires when the client has unfocused the TextBox. The event supplies a boolean 'enterPressed' which tells us whether or not the client pressed enter to lose focus.
local TextBox = script.Parent.TextBox
local SpeechLabel = script.Parent.SpeechLabel
TextBox.FocusLost:Connect(function(enterPressed)
if enterPressed then -- Checking if the enterPressed is true and not nil
-- The user must have pressed enter to exit the TextBox.
-- Could mean that they're done writing something.
SpeechLabel.Text = TextBox.Text
end
end)
All events have to be bound by using the :Connect method. This is what tells ROBLOX to start 'listening' to the event, to make sure the function fires every time this occurs.

dart mdv databinding does not update on change

I am trying to get databinding to work in dart. Basically im doing the same as in this video. Using pseudo code it looks like this:
mdv.init();
var p = new Person('john');
query('#someId').model = p;
In the html file i also have a template which works correctly. For now i am only trying to get one way databinding to work and although the template is correctly initialized, subsequent changes to the variable p are not visible in the template. I tried to trigger an update like this
node.model = null;
node.model = p;
This does not trigger an update however. But if i'm using a delay it does work:
node.model = null;
new Timer(new Duration(milliseconds:20),(){
node.model = p;
});
So i have a couple of questions about this:
Why does a change in the variable not reflect a change in the template ?
Is the template not supposed to update the way i'm doing it? Or is mdv/polymer not working the way it is intended?
Is it possible manually trigger an update of the template?
Would it be possible to easily convert one-way to two-way databinding (i.e. by making the Person class in the psuedocode observable or something)?
PS i searched and tried several things before posting here. I found a topic in which a custom polymer element is created, which seems more of an hassle then i would like it to be. I also tried the fancy-syntax lib (this did't improve it) and databinder (compile error). I also read a couple of pages about polymer, but i'm not sure what is relevant to dart and has not been deprecated (or 'stale' as the warning above the page mentions).
You need one of the following packages, to update bindings automatically on change.
mdv_observe
observe
documentation (Observables)
I would still recommend you to just add "polymer" as a dependency (remove mdv) to your pubspec.yaml. This way you won't have to handle version issues and you would have a guarantee of a "confirmed" set of packages working together.

ModX: Execute a php code when any Resource is created

I am working on a website created in ModX. I need to know the way I could execute a php code when any resource is created and also edit template variable associated to the created resource.
You can do this using a plugin, set to run on the OnDocFormSave event. This event has a mode property which will be set to new when the document being saved has just been created - you can do a simple check for this to prevent the plugin being run every time a document is saved.
To set a TV value for the current resource, do this:
// get the required TV object by name (or id)
$tv = $modx->getObject('modTemplateVar',array('name'=>'tvName'));
// set the new value and save it
$tv->setValue($modx->resource->get('id'), $newValue);
$tv->save();
The answer by okyanet is correct, but I've added details for those unfamiliar with MODX.
Create a plugin, and configure it to execute on the two system events 'onBeforeDocFormSave' and 'onDocFormSave'. The two events are fired just before and just after a resource is saved. When a resource is saved, the $mode variable is available to your plugin, and if it is a new resource it's value is modSystemEvent::MODE_NEW and if an update its value is modSystemEvent:MODE_UPD
I've written a gist that includes the full code with examples:
https://gist.github.com/2768300
This example shows you how to target either event through a switch statement, and how to further target the 'new' or 'update' status of the action. For intercepting and changing resource fields, its quite easy using the onBeforeDocFormSave event as you can simply change any resource fieldname with $resource->set('yourFieldname'). There is no $resource->save() required as this happens automatically after this event.
It's apparently much more difficult to save a tv using the onBeforeDocFormSave event, because of the way tvs are processed, so therefore the example shows how to update a tv using the system event 'onDocFormSave'. Again there is no $resource->save() required as tvs are saved immediately when you call 'setValue' on them.
A plugin could be made to function requiring only one of the system events, but as there are advantages to using both states as shown above, and to help explain, I have used both.

Resources