Skip to content

Commit

Permalink
Added source code with README
Browse files Browse the repository at this point in the history
  • Loading branch information
nurupo committed Sep 28, 2014
1 parent 7fd3a0d commit b537414
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
72 changes: 72 additions & 0 deletions pause_click.c
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*
* 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 <vlc_common.h>
#include <vlc_filter.h>
#include <vlc_mouse.h>
#include <vlc_playlist.h>
#include <vlc_plugin.h>

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;
}

0 comments on commit b537414

Please sign in to comment.