ray2501 / tkvlc

A demo to embed libVLC to Tk toolkit widget (Tcl version)
MIT License
5 stars 0 forks source link
libvlc tcl tcltk

tkvlc

libVLC is the core engine and the interface to the multimedia framework on which VLC media player is based.

It is a demo to embed libVLC to a Tk toolkit frame widget.

It involves making a frame widget in Tcl, and then passing its Windows HWND or X Window ID to C (use winfo id window) to initialize the libVLC media player.

User also can use --with-tk-photo flag to disable/enable to allow for photo images. This feature "allow for photo images" is from AndroWish project and written by Christian Werner. Default is yes.

User also can use this extension in console program, just not pass HWND or photo when using tkvlc::init to initialize (after version 0.4). However, tkvlc in console program now only work when interactive with tclsh.

License

MIT

Implement commands

tkvlc::init HANDLE ?HWND|photo?
HANDLE open filename
HANDLE openurl url
HANDLE play
HANDLE pause
HANDLE stop
HANDLE isplaying
HANDLE volume ?value?
HANDLE duration
HANDLE time ?value?
HANDLE position ?value? HANDLE isseekable
HANDLE state
HANDLE rate ?value?
HANDLE version
HANDLE destroy
HANDLE event ?cmd?
HANDLE repeat ?flag?
HANDLE info

duration get duration (in second) of movie time.

time get or set the current movie time (in second).

position get or set movie position as percentage between 0.0 and 1.0.

isseekable return true if the media player can seek.

state get current movie state.

rate get or set relative playback speed

repeat get or set replay flag

event get or set event callback

info return array set list with information media player

Movie state has states (string): idle, opening, buffering, playing, paused, stopped, ended, and error.

The event callback is invoked with an additional argument, which is made up of the event type (string): media, state, time, position, audio, and frame.

The event type frame occurs when new pixels have been rendered into a photo image.

UNIX BUILD

Only test on openSUSE LEAP 42.2 and Ubuntu 14.04.

First is to install libVLC development files. Below is an example for openSUSE:

sudo zypper in vlc-devel

Below is an example for Ubuntu:

sudo apt-get install libvlc-dev

And please notice, I think user still needs VLC codec package when playing a multimedia file.

Building under most UNIX systems is easy, just run the configure script and then run make. For more information about the build process, see the tcl/unix/README file in the Tcl src dist. The following minimal example will install the extension in the /opt/tcl directory.

$ cd tkvlc
$ ./configure --prefix=/opt/tcl
$ make
$ make install

If you need setup directory containing tcl configuration (tclConfig.sh), below is an example:

$ cd tkvlc
$ ./configure --with-tcl=/opt/activetcl/lib
$ make
$ make install

I enable TEA_PROG_WISH check, because this extension needs Tk toolkit. So if you need specify Tk include path, below is an example:

$ cd tkvlc
$ ./configure --with-tkinclude=/usr/include/tk
$ make
$ make install

WINDOWS BUILD

MSYS2/MinGW-W64

VLC binary installers for Windows do not include the LibVLC SDK.

To build this extension, user needs libVLC import libraries and development headers. Please check LibVLC_Tutorial. Copy libraries to C:\msys64\mingw64\lib and headers (vlc folder) to C:\msys64\mingw64\include.

When execute tkvlc, user needs libvlc.dll, libvlccore.dll and plugins files.

Next step is to build tkvlc.

$ ./configure --with-tcl=/c/tcl/lib
$ make
$ make install

Example

Please check example folder.