diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ae1b72b --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +PREFIX = /usr +LD = ld +CC = cc +INSTALL = install +CFLAGS = -g -O2 -Wall -Wextra +LDFLAGS = +VLC_PLUGIN_CFLAGS := $(shell pkg-config --cflags vlc-plugin) +VLC_PLUGIN_LIBS := $(shell pkg-config --libs vlc-plugin) + +libdir = $(PREFIX)/lib +plugindir = $(libdir)/vlc/plugins + +override CC += -std=gnu99 +override CPPFLAGS += -DPIC -I. -Isrc +override CFLAGS += -fPIC +override LDFLAGS += -Wl,-no-undefined,-z,defs + +override CPPFLAGS += -DMODULE_STRING=\"pause_click\" +override CFLAGS += $(VLC_PLUGIN_CFLAGS) +override LDFLAGS += $(VLC_PLUGIN_LIBS) + +TARGETS = libpause_click_plugin.so + +all: libpause_click_plugin.so + +install: all + mkdir -p -- $(DESTDIR)$(plugindir)/video_filter + $(INSTALL) --mode 0755 libpause_click_plugin.so $(DESTDIR)$(plugindir)/video_filter + +install-strip: + $(MAKE) install INSTALL="$(INSTALL) -s" + +uninstall: + rm -f $(plugindir)/video_filter/libpause_click_plugin.so + +clean: + rm -f -- libpause_click_plugin.so *.o + +mostlyclean: clean + +SOURCES = pause_click.c + +$(SOURCES:%.c=%.o): %: pause_click.c + +libpause_click_plugin.so: $(SOURCES:%.c=%.o) + $(CC) $(LDFLAGS) -shared -o $@ $^ + +.PHONY: all install install-strip uninstall clean mostlyclean diff --git a/README.md b/README.md new file mode 100644 index 0000000..09c5769 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# Pause Click plugin for VLC +This plugin allows you to pause/play a video by clicking on the video image. + +## Supported versions of VLC +Tested to work on VLC 2.1.5, so supposedly should work on 2.1.x versions. + +Doesn't work on VLC 3.x because of API changes. + +## Install + +### Debian +Get required libraries and tools: +```bash +sudo apt-get install build-essential pkg-config libvlccore-dev +``` + +Build and install: +```bash +make +sudo make install +``` + +## Usage +1. Go into advanced preferences: Tools -> Preferences -> Show settings -> All +2. Enable/Disable the plugin with a checkbox: (in advanced preferences) Video -> Filters -> Pause/Play video on mouse click +3. Restart VLC +4. Play a video +5. Click on video picture to pause/play the video diff --git a/pause_click.c b/pause_click.c new file mode 100644 index 0000000..8c24412 --- /dev/null +++ b/pause_click.c @@ -0,0 +1,72 @@ +/***************************************************************************** + * pause_click.c : A filter that allows to pause/play a video by a mouse click + ***************************************************************************** + * Copyright (C) 2014 Maxim Biro + * + * Authors: Maxim Biro + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#else +# define N_(str) (str) +#endif + +#include +#include +#include +#include +#include + +int Open(vlc_object_t *); + +vlc_module_begin() + set_description(N_("Pause/Play video on mouse click")) + set_shortname(N_("Pause click")) + set_capability("video filter2", 0) + // there might be a better place for it + set_category(CAT_VIDEO) + set_subcategory(SUBCAT_VIDEO_VFILTER) + set_callbacks(Open, NULL) +vlc_module_end() + +int mouse(filter_t *p_filter, vlc_mouse_t *p_mouse_out, const vlc_mouse_t *p_mouse_old, const vlc_mouse_t *p_mouse_new) +{ + if (vlc_mouse_HasPressed(p_mouse_old, p_mouse_new, MOUSE_BUTTON_LEFT)) { + playlist_t* p_playlist = pl_Get((vlc_object_t *)p_filter); + playlist_Control(p_playlist, (playlist_Status(p_playlist) == PLAYLIST_RUNNING ? PLAYLIST_PAUSE : PLAYLIST_PLAY), 0); + } + + // don't propagate any mouse change + return VLC_EGENERIC; +} + +picture_t *filter(filter_t *p_filter, picture_t *p_pic_in) +{ + // don't alter picture + return p_pic_in; +} + +int Open(vlc_object_t *p_this) +{ + filter_t *p_filter = (filter_t *)p_this; + + p_filter->pf_video_filter = filter; + p_filter->pf_video_mouse = mouse; + + return VLC_SUCCESS; +}