diff options
-rw-r--r-- | src/main.cpp | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/src/main.cpp b/src/main.cpp index 6f3ce18..3ee071a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,6 +9,15 @@ #include <fstream> #include <filesystem> #include <stdlib.h> +#ifdef __unix +#include <unistd.h> +#include <spawn.h> +#elif __posix +#include <unistd.h> +#include <spawn.h> +#elif _WIN32 +#include <windows.h> +#endif #include "tui.hpp" #include "video.hpp" @@ -60,39 +69,42 @@ void parseSysArgs(int argc, char **argv) { } } + + int main(int argc, char **argv) { parseSysArgs(argc, argv); - + #ifdef _WIN32 + start mpv + bool CreateProcessA() + #elif __unix + extern char **environ; - validateStructConversions(); - - // YtdlpWrapper yt; - // Video::video vid = yt.getVideoByUrl("https://youtu.be/jy5x7bDYd4o?list=OLAK5uy_kSLxuOA_vBO8SsXaI6PjJbqvsIBnBReGM"); - // cout << vid.id << ", " << vid.url << endl; - // yt.~YtdlpWrapper(); + int i{0}; + while ((environ[i]) != nullptr) { - // vector<Video::video> response = yt.searchVideos("factorio"); - // for (Video::video i: response) { + cout << environ[i++] << endl; + } + pid_t pid{0}; + fs::path vidFile("It's Time to Celebrate [K3qjudqERKU].webm"); + char *const mpvArgs[] = {strdup("mpv"), strdup(fs::absolute(vidFile).c_str()), nullptr}; + + i = 0; + while ((mpvArgs[i]) != nullptr) { - // cout << i.id << ", " << i.url << ", " << endl; - // } + cout << mpvArgs[i++] << " "; + } + cout << endl; - // nlohmann::json j = yt.getJsonSearch("the very thought of you"); - // cout << j << endl; + int result = posix_spawnp(&pid, mpvArgs[0], NULL, NULL, mpvArgs, environ); + if (result != 0) { - // SqliteInterface data; + cout << "ERROR RUNNING " << mpvArgs[0] << "! Error code " << result << ": " << strerror(result) << endl; + } else { - // vector<string> instances = getInstances(); - // for (auto i: instances) { - // cout << i << " "; - // } - // cout << endl; + cout << "pid: " << pid << endl; + } - string searchTerm; - int searchingFor{-1}; + #endif - Tui ux; - ux.renderSearchBar(searchTerm, searchingFor); - cout << searchTerm << searchingFor << endl; } \ No newline at end of file |