aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-09 03:35:56 +0200
committerdec05eba <dec05eba@protonmail.com>2019-08-09 03:36:07 +0200
commit73b077835dc6085c2642451fa7dbde629b9eadfc (patch)
treed6abfaae58f9ee918fda556b36a8078825cb2799 /include
parente061971e5f1dee5a6e1541bc88a192e9ca8e9422 (diff)
Readd video seek, make search asynchronous
Diffstat (limited to 'include')
-rw-r--r--include/Body.hpp4
-rw-r--r--include/QuickMedia.hpp4
-rw-r--r--include/VideoPlayer.hpp31
3 files changed, 31 insertions, 8 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 5d16898..a2db62a 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -20,6 +20,8 @@ namespace QuickMedia {
bool visible;
};
+ using BodyItems = std::vector<std::unique_ptr<BodyItem>>;
+
class Body {
public:
Body(sf::Font &font);
@@ -46,7 +48,7 @@ namespace QuickMedia {
sf::Text title_text;
sf::Text progress_text;
int selected_item;
- std::vector<std::unique_ptr<BodyItem>> items;
+ BodyItems items;
std::thread thumbnail_load_thread;
bool draw_thumbnails;
private:
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 7534439..90ceddd 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "Body.hpp"
#include "SearchBar.hpp"
#include "Page.hpp"
#include "Storage.hpp"
@@ -9,9 +10,9 @@
#include <SFML/Graphics/RenderWindow.hpp>
#include <json/value.h>
#include <unordered_set>
+#include <future>
namespace QuickMedia {
- class Body;
class Plugin;
class Program {
@@ -43,5 +44,6 @@ namespace QuickMedia {
Path content_storage_file;
Json::Value content_storage_json;
std::unordered_set<std::string> watched_videos;
+ std::future<BodyItems> search_suggestion_future;
};
} \ No newline at end of file
diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp
index 9d30dc5..2266a16 100644
--- a/include/VideoPlayer.hpp
+++ b/include/VideoPlayer.hpp
@@ -4,12 +4,14 @@
#include <SFML/System/Clock.hpp>
#include <stdio.h>
#include <functional>
-#include <thread>
+#include <json/value.h>
#include <sys/un.h>
+#include <X11/Xlib.h>
namespace QuickMedia {
using EventCallbackFunc = std::function<void(const char *event_name)>;
+ using VideoPlayerWindowCreateCallback = std::function<void(sf::WindowHandle window)>;
// Currently this video player launches mpv and embeds it into the QuickMedia window
class VideoPlayer {
@@ -22,11 +24,17 @@ namespace QuickMedia {
FAIL_TO_CONNECT_TIMEOUT,
FAIL_NOT_CONNECTED,
FAIL_TO_SEND,
+ FAIL_TO_FIND_WINDOW,
+ FAIL_TO_FIND_WINDOW_TIMEOUT,
+ UNEXPECTED_WINDOW_ERROR,
+ FAIL_TO_READ,
+ READ_TIMEOUT,
+ READ_INCORRECT_TYPE,
INIT_FAILED
};
// @event_callback is called from another thread
- VideoPlayer(EventCallbackFunc event_callback);
+ VideoPlayer(EventCallbackFunc event_callback, VideoPlayerWindowCreateCallback window_create_callback);
~VideoPlayer();
VideoPlayer(const VideoPlayer&) = delete;
VideoPlayer& operator=(const VideoPlayer&) = delete;
@@ -37,20 +45,31 @@ namespace QuickMedia {
Error update();
Error toggle_pause();
+
+ // Progress is in range [0..1]
+ Error get_progress(double *result);
+ // Progress is in range [0..1]
+ Error set_progress(double progress);
private:
Error send_command(const char *cmd, size_t size);
Error launch_video_process(const char *path, sf::WindowHandle parent_window);
- void read_ipc_func();
+ VideoPlayer::Error read_ipc_func();
private:
pid_t video_process_id;
int ipc_socket;
bool connected_to_ipc;
- sf::Clock ipc_connect_retry_timer;
+ sf::Clock retry_timer;
int connect_tries;
+ int find_window_tries;
struct sockaddr_un ipc_addr;
char ipc_server_path[L_tmpnam];
EventCallbackFunc event_callback;
- std::thread event_read_thread;
- bool alive;
+ VideoPlayerWindowCreateCallback window_create_callback;
+ sf::WindowHandle window_handle;
+ sf::WindowHandle parent_window;
+ Display *display;
+ unsigned int request_id;
+ unsigned int expected_request_id;
+ Json::Value request_response_data;
};
}