|
|
|
|
Reply From: |
SuperUserNameMan |
If you only want to play fullscreen video with sound (and eventually subtitles), you can include ffplay from ffmpeg into a sub directory of your project, and run it using the OS.execute() function.
extends Control
var pid = null;
func _ready(): #{
pass
#}
func play(videopath): #{
pid = OS.execute("bin/ffplay",["-autoexit", "-exitonkeydown", "-exitonmousedown", "-fs", videopath ],true);
#}
func _on_Play_pressed(): play("video/test.mp4");
According to my test, under Windows, specifying the .exe extension is not mandatory. This mean this code should work on all platforms.
Thanks, this is a great workaround.
SteveSmith | 2022-06-17 13:08
Does this still work? I think I have everything configured correctly, but still get the errors below?
extends Control
var pid = null;
func _ready(): #{
pass
#}
func play(videopath): #{
pid = OS.execute("res://bin/ffplay",["-autoexit", "-exitonkeydown", "-exitonmousedown", "-fs", videopath ],true);
#}
func _on_Play_pressed(): play("res://assets/videos/P1010293.MP4");
Error from Godot Console:
E 0:00:01.658 execute: Condition “ret == 0” is true. Returned: ERR_CANT_FORK
<C++ Source> platform/windows/os_windows.cpp:2905 @ execute()
VideoControl.gd:10 @ play()
VideoControl.gd:13 @ _on_Play_pressed()
Error from Web Browser Dev Tools:
tmp_js_export.js:369 ERROR: OS::execute() must be implemented in Javascript via ‘engine.setOnExecute’ if required.
at: execute (platform/javascript/os_javascript.cpp:891) - Condition “failed” is true. Returned: ERR_UNAVAILABLE
ChildLearning.Club | 2022-10-20 04:07
Does it work for you in the editor?
SteveSmith | 2022-10-20 07:11
I didn’t get any errors before running the program, if that is what you are asking? It was not until after running it and hitting the connected _on_Play_pressed button.
ChildLearning.Club | 2022-10-20 07:18
It’s just that the error mentions Javascript, so I wondered if it was only failing after exporting.
SteveSmith | 2022-10-20 07:38
Yes, that is the error I get after the web export.
ChildLearning.Club | 2022-10-20 07:58
But does it work when running in the editor?
SteveSmith | 2022-10-20 08:07
I don’t get any video to display, or play, in the editor or otherwise.
ChildLearning.Club | 2022-10-20 08:08