This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+2 votes

Hello,

I am trying to run external application with arguments.
For code test I try to run VLC with some parameters.

I Use OS.execute(), which works, opens the movie, but when I pass the arguments like
--noaudio, it doesn`t work, audio is still playing after program opens.

I tried it via normal command line, the argument opens the movie with no audio, but when running it via OS.execute(), the argument does nothing.

var array = ["--noaudio"]
var args = PoolStringArray(array)
OS.execute("D:\\Downloads\\movie.mkv", args, true)

Is the issue in my code? In the future we will need to run TexturePacker that will be creating atlases from textures, but it needs a lot of arguments.

in Engine by (22 points)

1 Answer

+1 vote
Best answer

Are you sure that's the right way to call it

for example this would not work

func _on_Button_pressed():
    OS.execute("c:\\temp\\test.txt", args, true)

but this would

func _on_Button_pressed():
    var array = ["c:\\temp\\test.txt"]
    var args = PoolStringArray(array)
    OS.execute("C:\\Windows\\System32\\notepad.exe", args, true)

so in your situation you may need to include the path for VLC

by (116 points)
selected by

You were right, the correct code was this:

var array = ["D:\\Downloads\\movie.mkv", "--noaudio"]
var args = PoolStringArray(array)
OS.execute("D:\\Programs\\VLC\\vlc.exe", args, false)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.