aboutsummaryrefslogtreecommitdiff
path: root/src/VideoPlayer.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-05 00:37:57 +0200
committerdec05eba <dec05eba@protonmail.com>2019-08-05 00:38:00 +0200
commit7e8a2f23a40e6374ddfb551920257846021e86fa (patch)
treee9fae05dbc3c2b83f580f5c40fd4cae97e03b536 /src/VideoPlayer.cpp
parent887b6003010a0c455667fb67c12a5577c60498db (diff)
Skip youtube ads in search
Diffstat (limited to 'src/VideoPlayer.cpp')
-rw-r--r--src/VideoPlayer.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index e3dab43..ee4c715 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -14,8 +14,22 @@ namespace QuickMedia {
VideoPlayer *video_player = (VideoPlayer*)rawVideo;
++video_player->redrawCounter;
}
+
+ static void check_error(int status) {
+ if(status < 0)
+ fprintf(stderr, "mpv api error: %s\n", mpv_error_string(status));
+ }
+
+ static void mpv_set_option_bool(mpv_handle *mpv, const char *option, bool value) {
+ int int_value = value;
+ check_error(mpv_set_option(mpv, option, MPV_FORMAT_FLAG, &int_value));
+ }
+
+ static void mpv_set_option_int64(mpv_handle *mpv, const char *option, int64_t value) {
+ check_error(mpv_set_option(mpv, option, MPV_FORMAT_INT64, &value));
+ }
- VideoPlayer::VideoPlayer(unsigned int width, unsigned int height, const char *file, bool loop) :
+ VideoPlayer::VideoPlayer(unsigned int width, unsigned int height, sf::WindowHandle window_handle, const char *file, bool loop) :
redrawCounter(0),
onPlaybackEndedCallback(nullptr),
mpv(nullptr),
@@ -33,20 +47,23 @@ namespace QuickMedia {
if(!mpv)
throw VideoInitializationException("Failed to create mpv handle");
- //mpv_set_option_string(mpv, "input-default-bindings", "yes");
- //mpv_set_option_string(mpv, "input-vo-keyboard", "yes");
- mpv_set_option_string(mpv, "cache-secs", "120");
- mpv_set_option_string(mpv, "demuxer-max-bytes", "20M");
- mpv_set_option_string(mpv, "demuxer-max-back-bytes", "10M");
+ //check_error(mpv_set_option_string(mpv, "input-default-bindings", "yes"));
+ //check_error(mpv_set_option_string(mpv, "input-vo-keyboard", "yes"));
+ check_error(mpv_set_option_string(mpv, "cache-secs", "120"));
+ check_error(mpv_set_option_string(mpv, "demuxer-max-bytes", "20M"));
+ check_error(mpv_set_option_string(mpv, "demuxer-max-back-bytes", "10M"));
+
+ //mpv_set_option_bool(mpv, "osc", true);
+ //mpv_set_option_int64(mpv, "wid", window_handle);
if(mpv_initialize(mpv) < 0)
throw VideoInitializationException("Failed to initialize mpv");
- mpv_set_option_string(mpv, "vo", "opengl-cb");
- mpv_set_option_string(mpv, "hwdec", "auto");
+ check_error(mpv_set_option_string(mpv, "vo", "opengl-cb"));
+ check_error(mpv_set_option_string(mpv, "hwdec", "auto"));
if(loop)
- mpv_set_option_string(mpv, "loop", "inf");
+ check_error(mpv_set_option_string(mpv, "loop", "inf"));
mpvGl = (mpv_opengl_cb_context*)mpv_get_sub_api(mpv, MPV_SUB_API_OPENGL_CB);
if(!mpvGl)