Commit 65de9dd7 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Patch by Frans van Veen and Jasper Alias with modifications by me.

New;
- Mozilla/firefox toolbar for Linux
- Play, Pause, Stop, Fullscreen and Mute buttons
- Timeline, you can click on any place in the timeline and the movie will jump to it

Fixed: 
- Coding style, readibility
- Maximum 80 characters per line
- Major memory leak, due to not releasing image data

Known bugs:
- updating timeline not working well because callback function not working "libvlc_event_attach......"
- white line below the toolbar
- play/pause toggle not working well because ticket #1065
parent cbeed909
...@@ -84,6 +84,7 @@ Farzaneh Sarafraz <farzaneh at farsiweb dot info> - Persian localisation ...@@ -84,6 +84,7 @@ Farzaneh Sarafraz <farzaneh at farsiweb dot info> - Persian localisation
Fouzia Bourai <fbourai at cerist dot dz> - Arabic localisation Fouzia Bourai <fbourai at cerist dot dz> - Arabic localisation
François Seingier <francois.seingier at club-internet.fr> - TTL setting in the wx stream output dialog François Seingier <francois.seingier at club-internet.fr> - TTL setting in the wx stream output dialog
Frank Chao <frank0624 at gmail.com> - Chinese Traditional translation Frank Chao <frank0624 at gmail.com> - Chinese Traditional translation
Frans van Veen <f.m.j.c.vanveen at student.hhs.nl> - Mozilla plugin toolbar
Fumio Nakayama <endymion at ca2.so-net.ne.jp> - Japanese translation Fumio Nakayama <endymion at ca2.so-net.ne.jp> - Japanese translation
Gabor Kelemen <kelemeng at gnome dot hu> - Hungarian translation Gabor Kelemen <kelemeng at gnome dot hu> - Hungarian translation
Geoffrey Roussel <meka321 at hotmail dot com> - Christmas easter egg Artwork Geoffrey Roussel <meka321 at hotmail dot com> - Christmas easter egg Artwork
...@@ -103,8 +104,8 @@ Ilkka Ollakka - SDP bitrate patch, various VLM fixes, transcode afilter/vfilter ...@@ -103,8 +104,8 @@ Ilkka Ollakka - SDP bitrate patch, various VLM fixes, transcode afilter/vfilter
Jan David Mol <jjdmol at gmail.com> - Suggested some flags for ffmpeg building Jan David Mol <jjdmol at gmail.com> - Suggested some flags for ffmpeg building
Jan Gerber <j at v2v dot org> - patch theora decoding aspect ratio Jan Gerber <j at v2v dot org> - patch theora decoding aspect ratio
Jan Van Boghout <vlc at macrabbit.com> - iTunes like slider for OSX intf Jan Van Boghout <vlc at macrabbit.com> - iTunes like slider for OSX intf
Javier Varela <tonxabar at hotmail.com> - Spanish translation Jasper Alias <j.alias at student.hhs.nl>- Mozilla plugin toolbar
Jean-Alexis Montignies <ja at sente.ch> - coreaudio multiple streams fix Javier Varela <tonxabar at hotmail.com> - Spanish translation Jean-Alexis Montignies <ja at sente.ch> - coreaudio multiple streams fix
Jean-Baptiste Le Stang <jp.lestand at lestang.org> - Equalizer-GUI-fixes (OSX), Universal Binary Script Jean-Baptiste Le Stang <jp.lestand at lestang.org> - Equalizer-GUI-fixes (OSX), Universal Binary Script
Jean-Philippe Grimaldi <jeanphi at via.ecp.fr> - bug fixes Jean-Philippe Grimaldi <jeanphi at via.ecp.fr> - bug fixes
Dugal Harris <dugalh at protoclea dot. co dot za > - ActiveX bug fixes Dugal Harris <dugalh at protoclea dot. co dot za > - ActiveX bug fixes
......
...@@ -5805,7 +5805,7 @@ then ...@@ -5805,7 +5805,7 @@ then
MOZILLA_CONFIG_H="${firefox_include}/mozilla-config.h" MOZILLA_CONFIG_H="${firefox_include}/mozilla-config.h"
fi fi
if grep '^#define MOZ_X11 1' ${MOZILLA_CONFIG_H} 2>&1 > /dev/null ; then if grep '^#define MOZ_X11 1' ${MOZILLA_CONFIG_H} 2>&1 > /dev/null ; then
VLC_ADD_LIBS([mozilla], [${X_LIBS} ${X_PRE_LIBS} -lX11 -lXt]) VLC_ADD_LIBS([mozilla], [${X_LIBS} ${X_PRE_LIBS} -lX11 -lXt -lXpm])
fi fi
VLC_ADD_CPPFLAGS([mozilla],[${CPPFLAGS}]) VLC_ADD_CPPFLAGS([mozilla],[${CPPFLAGS}])
VLC_ADD_LDFLAGS([mozilla],[${MOZILLA_LDFLAGS}]) VLC_ADD_LDFLAGS([mozilla],[${MOZILLA_LDFLAGS}])
...@@ -5842,10 +5842,10 @@ then ...@@ -5842,10 +5842,10 @@ then
AC_CHECK_LIB(Xt,XtStrings, AC_CHECK_LIB(Xt,XtStrings,
[ [
VLC_ADD_CPPFLAGS([mozilla],[${X_CFLAGS}]) VLC_ADD_CPPFLAGS([mozilla],[${X_CFLAGS}])
VLC_ADD_LIBS([mozilla],[${X_LIBS} ${X_PRE_LIBS} -lXt -lX11 -lSM -lICE]) VLC_ADD_LIBS([mozilla],[${X_LIBS} ${X_PRE_LIBS} -lXt -lX11 -lSM -lICE -lXpm])
], ],
[], [],
[[${X_LIBS} ${X_PRE_LIBS} -lX11 -lSM -lICE] [[${X_LIBS} ${X_PRE_LIBS} -lX11 -lSM -lICE -lXpm]
]) ])
LDFLAGS="${LDFLAGS_save}" LDFLAGS="${LDFLAGS_save}"
fi fi
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
# include <X11/Xlib.h> # include <X11/Xlib.h>
# include <X11/Intrinsic.h> # include <X11/Intrinsic.h>
# include <X11/StringDefs.h> # include <X11/StringDefs.h>
# include <X11/X.h>
#endif #endif
class VlcPlugin class VlcPlugin
...@@ -87,6 +88,14 @@ public: ...@@ -87,6 +88,14 @@ public:
#if XP_UNIX #if XP_UNIX
int setSize(unsigned width, unsigned height); int setSize(unsigned width, unsigned height);
Window getVideoWindow()
{ return npvideo; };
void setVideoWindow(Window window)
{ npvideo = window; };
Window getControlWindow()
{ return npcontrol; };
void setControlWindow(Window window)
{ npcontrol = window; };
#endif #endif
uint16 i_npmode; /* either NP_EMBED or NP_FULL */ uint16 i_npmode; /* either NP_EMBED or NP_FULL */
...@@ -113,6 +122,7 @@ private: ...@@ -113,6 +122,7 @@ private:
#endif #endif
#if XP_UNIX #if XP_UNIX
unsigned int i_width, i_height; unsigned int i_width, i_height;
Window npvideo, npcontrol;
#endif #endif
}; };
...@@ -151,6 +161,7 @@ private: ...@@ -151,6 +161,7 @@ private:
"video/x-ms-asf:asf,asx:Windows Media Video;" \ "video/x-ms-asf:asf,asx:Windows Media Video;" \
"application/x-mplayer2::Windows Media;" \ "application/x-mplayer2::Windows Media;" \
"video/x-ms-wmv:wmv:Windows Media;" \ "video/x-ms-wmv:wmv:Windows Media;" \
"video/x-ms-wvx:wvx:Windows Media Video;" \
/* Google VLC */ \ /* Google VLC */ \
"application/x-google-vlc-plugin::Google VLC plugin;" \ "application/x-google-vlc-plugin::Google VLC plugin;" \
/* WAV audio */ \ /* WAV audio */ \
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <X11/xpm.h>
/* Mozilla stuff */ /* Mozilla stuff */
#ifdef HAVE_MOZILLA_CONFIG_H #ifdef HAVE_MOZILLA_CONFIG_H
...@@ -45,7 +46,8 @@ ...@@ -45,7 +46,8 @@
/* Enable/disable debugging printf's for X11 resizing */ /* Enable/disable debugging printf's for X11 resizing */
#undef X11_RESIZE_DEBUG #undef X11_RESIZE_DEBUG
#define WINDOW_TEXT "(no video)" #define WINDOW_TEXT "Video is loading..."
#define CONTROL_HEIGHT 45
/***************************************************************************** /*****************************************************************************
* Unix-only declarations * Unix-only declarations
...@@ -53,6 +55,7 @@ ...@@ -53,6 +55,7 @@
#ifdef XP_UNIX #ifdef XP_UNIX
static void Redraw( Widget w, XtPointer closure, XEvent *event ); static void Redraw( Widget w, XtPointer closure, XEvent *event );
static void ControlHandler( Widget w, XtPointer closure, XEvent *event );
static void Resize( Widget w, XtPointer closure, XEvent *event ); static void Resize( Widget w, XtPointer closure, XEvent *event );
#endif #endif
...@@ -184,7 +187,8 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -184,7 +187,8 @@ int16 NPP_HandleEvent( NPP instance, void * event )
{ {
if( libvlc_playlist_isplaying(p_vlc, NULL) ) if( libvlc_playlist_isplaying(p_vlc, NULL) )
{ {
libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_vlc, NULL); libvlc_media_instance_t *p_md =
libvlc_playlist_get_media_instance(p_vlc, NULL);
if( p_md ) if( p_md )
{ {
libvlc_toggle_fullscreen(p_md, NULL); libvlc_toggle_fullscreen(p_md, NULL);
...@@ -214,7 +218,8 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -214,7 +218,8 @@ int16 NPP_HandleEvent( NPP instance, void * event )
{ {
if( libvlc_playlist_isplaying(p_vlc, NULL) ) if( libvlc_playlist_isplaying(p_vlc, NULL) )
{ {
libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_vlc, NULL); libvlc_media_instance_t *p_md =
libvlc_playlist_get_media_instance(p_vlc, NULL);
if( p_md ) if( p_md )
{ {
hasVout = libvlc_media_instance_has_vout(p_md, NULL); hasVout = libvlc_media_instance_has_vout(p_md, NULL);
...@@ -240,7 +245,8 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -240,7 +245,8 @@ int16 NPP_HandleEvent( NPP instance, void * event )
PenMode( patCopy ); PenMode( patCopy );
/* seems that firefox forgets to set the following on occasion (reload) */ /* seems that firefox forgets to set the following on occasion (reload) */
SetOrigin(((NP_Port *)npwindow.window)->portx, ((NP_Port *)npwindow.window)->porty); SetOrigin(((NP_Port *)npwindow.window)->portx,
((NP_Port *)npwindow.window)->porty);
Rect rect; Rect rect;
rect.left = 0; rect.left = 0;
...@@ -438,11 +444,12 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -438,11 +444,12 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
SetWindowLong( oldwin, GWL_WNDPROC, (LONG)oldproc ); SetWindowLong( oldwin, GWL_WNDPROC, (LONG)oldproc );
} }
/* attach our plugin object */ /* attach our plugin object */
SetWindowLongPtr((HWND)drawable, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(p_plugin)); SetWindowLongPtr((HWND)drawable, GWLP_USERDATA,
reinterpret_cast<LONG_PTR>(p_plugin));
/* install our WNDPROC */ /* install our WNDPROC */
p_plugin->setWindowProc( (WNDPROC)SetWindowLong( drawable, p_plugin->setWindowProc( (WNDPROC)SetWindowLong( drawable,
GWL_WNDPROC, (LONG)Manage ) ); GWL_WNDPROC, (LONG)Manage ) );
/* change window style to our liking */ /* change window style to our liking */
LONG style = GetWindowLong((HWND)drawable, GWL_STYLE); LONG style = GetWindowLong((HWND)drawable, GWL_STYLE);
...@@ -475,22 +482,56 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -475,22 +482,56 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
#ifdef XP_UNIX #ifdef XP_UNIX
if( window && window->window ) if( window && window->window )
{ {
Window drawable = (Window) window->window; Window parent = (Window) window->window;
if( !curwin.window || drawable != (Window)curwin.window ) if( !curwin.window || (parent != (Window)curwin.window) )
{ {
Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display; Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display;
XResizeWindow( p_display, drawable, window->width, window->height ); XResizeWindow( p_display, parent, window->width, window->height );
Widget w = XtWindowToWidget( p_display, drawable );
XtAddEventHandler( w, ExposureMask, FALSE, (XtEventHandler)Redraw, p_plugin ); int i_blackColor = BlackPixel(p_display, DefaultScreen(p_display));
XtAddEventHandler( w, StructureNotifyMask, FALSE, (XtEventHandler)Resize, p_plugin );
Window video = XCreateSimpleWindow( p_display, parent, 0, 0,
window->width, window->height - CONTROL_HEIGHT, 0,
i_blackColor, i_blackColor );
Window controls = XCreateSimpleWindow( p_display, parent, 0,
window->height - CONTROL_HEIGHT-1, window->width,
CONTROL_HEIGHT-1, 0, i_blackColor, i_blackColor );
XMapWindow( p_display, parent );
XMapWindow( p_display, video );
XMapWindow( p_display, controls );
XFlush(p_display);
Widget w = XtWindowToWidget( p_display, parent );
XtAddEventHandler( w, ExposureMask, FALSE,
(XtEventHandler)Redraw, p_plugin );
XtAddEventHandler( w, StructureNotifyMask, FALSE,
(XtEventHandler)Resize, p_plugin );
XtAddEventHandler( w, ButtonReleaseMask, FALSE,
(XtEventHandler)ControlHandler, p_plugin );
/* callback */
/*
libvlc_media_instance_t *p_md;
libvlc_exception_t ex;
libvlc_exception_init(& ex );
p_md = libvlc_playlist_get_media_instance( p_plugin->getVLC(), &ex );
libvlc_exception_init( &ex );
libvlc_event_attach( libvlc_media_instance_event_manager( p_md, &ex ),
libvlc_MediaInstancePositionChanged, Redraw, NULL, &ex );
*/
/* set/change parent window */ /* set/change parent window */
libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL); libvlc_video_set_parent( p_vlc, (libvlc_drawable_t) video, NULL );
/* remember window */ /* remember window */
p_plugin->setWindow(*window); p_plugin->setWindow( *window );
p_plugin->setVideoWindow( video );
p_plugin->setControlWindow( controls );
Redraw( w, (XtPointer)p_plugin, NULL ); Redraw( w, (XtPointer)p_plugin, NULL );
} }
...@@ -507,7 +548,8 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -507,7 +548,8 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{ {
if( p_plugin->psz_target ) if( p_plugin->psz_target )
{ {
if( libvlc_playlist_add( p_vlc, p_plugin->psz_target, NULL, NULL ) != -1 ) if( libvlc_playlist_add( p_vlc, p_plugin->psz_target,
NULL, NULL ) != -1 )
{ {
if( p_plugin->b_autoplay ) if( p_plugin->b_autoplay )
{ {
...@@ -702,7 +744,8 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa ...@@ -702,7 +744,8 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
FillRect( hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) ); FillRect( hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) );
SetTextColor(hdc, RGB(255, 255, 255)); SetTextColor(hdc, RGB(255, 255, 255));
SetBkColor(hdc, RGB(0, 0, 0)); SetBkColor(hdc, RGB(0, 0, 0));
DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE); DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect,
DT_CENTER|DT_VCENTER|DT_SINGLELINE);
EndPaint( p_hwnd, &paintstruct ); EndPaint( p_hwnd, &paintstruct );
return 0L; return 0L;
...@@ -725,30 +768,261 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event ) ...@@ -725,30 +768,261 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event )
GC gc; GC gc;
XGCValues gcv; XGCValues gcv;
Window drawable = (Window) window.window; /* Toolbar */
XImage *p_playIcon = NULL;
XImage *p_pauseIcon = NULL;
XImage *p_stopIcon = NULL;
XImage *p_timeline = NULL;
XImage *p_timeKnob = NULL;
XImage *p_fscreen = NULL;
XImage *p_muteIcon = NULL;
XImage *p_unmuteIcon = NULL;
libvlc_media_instance_t *p_md = NULL;
float f_position = 0;
int i_playing = 0;
bool b_mute = false;
Window video = p_plugin->getVideoWindow();
Window control = p_plugin->getControlWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
gcv.foreground = BlackPixel( p_display, 0 ); gcv.foreground = BlackPixel( p_display, 0 );
gc = XCreateGC( p_display, drawable, GCForeground, &gcv ); gc = XCreateGC( p_display, video, GCForeground, &gcv );
XFillRectangle( p_display, drawable, gc, XFillRectangle( p_display, video, gc,
0, 0, window.width, window.height ); 0, 0, window.width, window.height - CONTROL_HEIGHT );
gcv.foreground = WhitePixel( p_display, 0 ); gcv.foreground = WhitePixel( p_display, 0 );
XChangeGC( p_display, gc, GCForeground, &gcv ); XChangeGC( p_display, gc, GCForeground, &gcv );
XDrawString( p_display, drawable, gc, XDrawString( p_display, video, gc,
window.width / 2 - 40, window.height / 2, window.width / 2 - 40, (window.height - CONTROL_HEIGHT) / 2,
WINDOW_TEXT, strlen(WINDOW_TEXT) ); WINDOW_TEXT, strlen(WINDOW_TEXT) );
/* RedrawToolbar */
gcv.foreground = BlackPixel( p_display, 0 );
gc = XCreateGC( p_display, control, GCForeground, &gcv );
XFillRectangle( p_display, control, gc,
0, 0, window.width, CONTROL_HEIGHT );
gcv.foreground = WhitePixel( p_display, 0 );
XChangeGC( p_display, gc, GCForeground, &gcv );
/* get media instance */
libvlc_exception_t ex;
libvlc_exception_init( &ex );
p_md = libvlc_playlist_get_media_instance( p_plugin->getVLC(), &ex );
libvlc_exception_clear( &ex );
/* get isplaying */
libvlc_exception_init( &ex );
i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
libvlc_exception_clear( &ex );
/* get mute info */
libvlc_exception_init(&ex);
b_mute = libvlc_audio_get_mute( p_plugin->getVLC(), &ex );
libvlc_exception_clear( &ex );
/* get movie position in % */
if( i_playing == 1 )
{
libvlc_exception_init( &ex );
f_position = libvlc_media_instance_get_position(p_md, &ex)*100;
libvlc_exception_clear( &ex );
}
libvlc_media_instance_release(p_md);
/* load icons */
XpmReadFileToImage( p_display, "/usr/share/vlc/mozilla/play.xpm",
&p_playIcon, NULL, NULL);
XpmReadFileToImage( p_display, "/usr/share/vlc/mozilla/pause.xpm",
&p_pauseIcon, NULL, NULL);
XpmReadFileToImage( p_display, "/usr/share/vlc/mozilla/stop.xpm",
&p_stopIcon, NULL, NULL );
XpmReadFileToImage( p_display, "/usr/share/vlc/mozilla/time_line.xpm",
&p_timeline, NULL, NULL);
XpmReadFileToImage( p_display, "/usr/share/vlc/mozilla/time_icon.xpm",
&p_timeKnob, NULL, NULL);
XpmReadFileToImage( p_display, "/usr/share/vlc/mozilla/fullscreen.xpm",
&p_fscreen, NULL, NULL);
XpmReadFileToImage( p_display, "/usr/share/vlc/mozilla/volume_max.xpm",
&p_muteIcon, NULL, NULL);
XpmReadFileToImage( p_display, "/usr/share/vlc/mozilla/volume_mute.xpm",
&p_unmuteIcon, NULL, NULL);
#if 1 /* DEBUG */
if( !p_playIcon )
{
fprintf(stderr, "Error: playImage not found\n");
}
if( !p_pauseIcon )
{
fprintf(stderr, "Error: pauseImage not found\n");
}
if( !p_stopIcon )
{
fprintf(stderr, "Error: stopImage not found\n");
}
if( !p_timeline )
{
fprintf(stderr, "Error: TimeLineImage not found\n");
}
if( !p_timeKnob )
{
fprintf(stderr, "Error: TimeIcon not found\n");
}
if( !p_fscreen )
{
fprintf(stderr, "Error: FullscreenImage not found\n");
}
if( !p_muteIcon )
{
fprintf(stderr, "Error: MuteImage not found\n");
}
if( !p_unmuteIcon )
{
fprintf(stderr, "Error: UnMuteImage not found\n");
}
#endif
/* position icons */
if( p_pauseIcon && (i_playing == 1) )
{
XPutImage( p_display, control, gc, p_pauseIcon, 0, 0, 4, 14,
p_pauseIcon->width, p_pauseIcon->height );
}
else if( p_playIcon )
{
XPutImage( p_display, control, gc, p_playIcon, 0, 0, 4, 14,
p_playIcon->width, p_playIcon->height );
}
if( p_stopIcon )
XPutImage( p_display, control, gc, p_stopIcon, 0, 0, 39, 14,
p_stopIcon->width, p_stopIcon->height );
if( p_fscreen )
XPutImage( p_display, control, gc, p_fscreen, 0, 0, 67, 21,
p_fscreen->width, p_fscreen->height );
if( p_unmuteIcon && b_mute )
{
XPutImage( p_display, control, gc, p_unmuteIcon, 0, 0, 94, 30,
p_unmuteIcon->width, p_unmuteIcon->height );
}
else if( p_muteIcon )
{
XPutImage( p_display, control, gc, p_muteIcon, 0, 0, 94, 30,
p_muteIcon->width, p_muteIcon->height );
}
if( p_timeline )
XPutImage( p_display, control, gc, p_timeline, 0, 0, 4, 4,
(window.width-8), p_timeline->height );
if( p_timeKnob && (f_position > 0) )
{
f_position = (((float)window.width-8)/100)*f_position;
XPutImage( p_display, control, gc, p_timeKnob, 0, 0, (4+f_position), 2,
p_timeKnob->width, p_timeKnob->height );
}
/* Cleanup */
if( p_playIcon ) XDestroyImage( p_playIcon );
if( p_pauseIcon ) XDestroyImage( p_pauseIcon );
if( p_stopIcon ) XDestroyImage( p_stopIcon );
if( p_timeline ) XDestroyImage( p_timeline );
if( p_timeKnob ) XDestroyImage( p_timeKnob );
if( p_fscreen ) XDestroyImage( p_fscreen );
if( p_muteIcon ) XDestroyImage( p_muteIcon );
if( p_unmuteIcon ) XDestroyImage( p_unmuteIcon );
XFreeGC( p_display, gc ); XFreeGC( p_display, gc );
} }
static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
{
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
const NPWindow& window = p_plugin->getWindow();
int i_height = window.height;
int i_width = window.width;
int i_xPos = event->xbutton.x;
int i_yPos = event->xbutton.y;
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_instance_t *p_md =
libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex);
libvlc_exception_clear( &ex );
/* jump in the movie */
if( i_yPos <= (i_height-30) )
{
vlc_int64_t f_length;
libvlc_exception_init( &ex );
f_length = libvlc_media_instance_get_length( p_md, &ex ) / 100;
libvlc_exception_clear( &ex );
f_length = (float)f_length *
( ((float)i_xPos-4 ) / ( ((float)i_width-8)/100) );
libvlc_exception_init( &ex );
libvlc_media_instance_set_time( p_md, f_length, &ex );
libvlc_exception_clear( &ex );
}
/* play/pause toggle */
if( (i_yPos > (i_height-30)) && (i_xPos > 4) && (i_xPos <= 39) )
{
int i_playing;
libvlc_exception_init( &ex );
i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
libvlc_exception_clear( &ex );
libvlc_exception_init( &ex );
if( i_playing == 1 )
libvlc_playlist_pause( p_plugin->getVLC(), &ex );
else
libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex );
libvlc_exception_clear( &ex );
}
/* stop */
if( (i_yPos > (i_height-30)) && (i_xPos > 39) && (i_xPos < 67) )
{
libvlc_exception_init( &ex );
libvlc_playlist_stop( p_plugin->getVLC(), &ex );
libvlc_exception_clear( &ex );
}
/* fullscreen */
if( (i_yPos > (i_height-30)) && (i_xPos >= 67) && (i_xPos < 94) )
{
libvlc_exception_init( &ex );
libvlc_set_fullscreen( p_md, 1, &ex );
libvlc_exception_clear( &ex );
}
/* mute toggle */
if( (i_yPos > (i_height-30)) && (i_xPos >= 94) && (i_xPos < 109))
{
libvlc_exception_init( &ex );
libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex );
libvlc_exception_clear( &ex );
}
libvlc_media_instance_release( p_md );
Redraw( w, closure, event );
}
static void Resize ( Widget w, XtPointer closure, XEvent *event ) static void Resize ( Widget w, XtPointer closure, XEvent *event )
{ {
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure); VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
const NPWindow& window = p_plugin->getWindow(); const NPWindow& window = p_plugin->getWindow();
Window drawable = (Window) window.window; Window drawable = p_plugin->getVideoWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
int i_ret; int i_ret;
...@@ -768,14 +1042,14 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event ) ...@@ -768,14 +1042,14 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
} }
#endif /* X11_RESIZE_DEBUG */ #endif /* X11_RESIZE_DEBUG */
if( ! p_plugin->setSize(window.width, window.height) ) if( ! p_plugin->setSize(window.width, (window.height - CONTROL_HEIGHT)) )
{ {
/* size already set */ /* size already set */
return; return;
} }
i_ret = XResizeWindow( p_display, drawable, window.width, window.height ); i_ret = XResizeWindow( p_display, drawable, window.width, (window.height - CONTROL_HEIGHT) );
#ifdef X11_RESIZE_DEBUG #ifdef X11_RESIZE_DEBUG
fprintf( stderr, fprintf( stderr,
...@@ -807,7 +1081,7 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event ) ...@@ -807,7 +1081,7 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
#endif /* X11_RESIZE_DEBUG */ #endif /* X11_RESIZE_DEBUG */
i_ret = XResizeWindow( p_display, base_window, i_ret = XResizeWindow( p_display, base_window,
window.width, window.height ); window.width, ( window.height - CONTROL_HEIGHT ) );
#ifdef X11_RESIZE_DEBUG #ifdef X11_RESIZE_DEBUG
fprintf( stderr, fprintf( stderr,
......
/* XPM */
static char * fullscreen_xpm[] = {
"26 20 5 1",
" c None",
". c #999999",
"+ c #989898",
"@ c #9A9A9A",
"# c #9B9B9B",
" . . ",
"... . . ...",
" .... .... ",
" ... ... ",
" .... +.+@+.@@..# .... ",
" ................ ",
" ...............@ ",
" ................ ",
" ................ ",
" ................ ",
" ................ ",
" ................ ",
" ................ ",
" ................ ",
" ................ ",
" .... .@+....@.@ .... ",
" ... ... ",
" .... .... ",
"... . . ...",
" . . "};
/* XPM */
static char * pause_xpm[] = {
"33 27 3 1",
"+ c None",
". c #999999",
"* c #FFFFFF",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++.............",
".............+++++++............."};
/* XPM */
static char * play_xpm[] = {
"34 27 3 1",
"+ c None",
". c #999999",
"* c #FFFFFF",
".+++++++++++++++++++++++++++++++++",
"....++++++++++++++++++++++++++++++",
"......++++++++++++++++++++++++++++",
".........+++++++++++++++++++++++++",
"...........+++++++++++++++++++++++",
"..............++++++++++++++++++++",
"................++++++++++++++++++",
"...................+++++++++++++++",
".....................+++++++++++++",
"........................++++++++++",
"..........................++++++++",
".............................+++++",
"...............................+++",
".................................+",
"...............................+++",
".............................+++++",
"..........................++++++++",
"........................++++++++++",
".....................+++++++++++++",
"...................+++++++++++++++",
"................++++++++++++++++++",
"..............++++++++++++++++++++",
"...........+++++++++++++++++++++++",
".........+++++++++++++++++++++++++",
"......++++++++++++++++++++++++++++",
"....++++++++++++++++++++++++++++++",
".+++++++++++++++++++++++++++++++++"};
/* XPM */
static char * skip_next_xpm[] = {
"30 18 2 1",
" c None",
". c #999999",
". . ..",
".. .. ..",
".... .... ..",
"..... ...... ..",
"....... ....... ..",
"......... ......... ..",
".......... .......... ..",
"............ ............ ..",
"............. ................",
"............. ............. ..",
"............ ............ ..",
".......... .......... ..",
"......... ......... ..",
"....... ....... ..",
"...... ..... ..",
".... .... ..",
".. .. ..",
". . .."};
/* XPM */
static char * skip_previous_xpm[] = {
"30 18 2 1",
" c None",
". c #999999",
".. . .",
".. .. ..",
".. .... ....",
".. ...... ......",
".. ....... .......",
".. ......... .........",
".. .......... ..........",
".. ............ ............",
".. ............. .............",
".. ............. .............",
".. ............ ............",
".. .......... ..........",
".. ......... .........",
".. ....... .......",
".. ...... ......",
".. .... ....",
".. .. ..",
".. . ."};
/* XPM */
static char * fs_stop_xpm[] = {
"27 27 2 1",
" c None",
". c #999999",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"...........................",
"..........................."};
/* XPM */
static char * time_slider_knob_xpm[] = {
"8 6 3 1",
" c None",
". c #999999",
"* c #999999",
" *..* ",
" *....* ",
"*......*",
"*......*",
" *....* ",
" *..* "};
/* XPM */
static char * time_line2_xpm[] = {
"518 2 2 1",
" c None",
". c #999999",
"......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................"};
/* XPM */
static char * volume_knob_xpm[] = {
"9 9 10 1",
" c None",
". c #989898",
"+ c #999999",
"@ c #8D8D8D",
"# c #7A7A7A",
"$ c #686868",
"% c #272727",
"& c #262626",
"* c #2F2F2F",
"= c #585858",
" ... ",
" .+@#@+. ",
" +$%&%$+ ",
".@%*=*%@.",
".#&=+=&#.",
".@%*=*%@.",
" +$%&%$+ ",
" .+@#@+. ",
" ... "};
/* XPM */
static char * volume_max_xpm[] = {
"15 13 3 1",
" c None",
". c #999999",
"+ c #9A9A9A",
" ",
" . . ",
" .. . ",
" ... . . ",
" ..... . .",
"....... + . .",
"....... + .",
"....... + + .",
" .... . .",
" ... + . ",
" .. . ",
" . ",
" "};
/* XPM */
static char * volume_mute_xpm[] = {
"7 11 2 1",
" c None",
". c #999999",
" .",
" ..",
" ...",
" ....",
".......",
".......",
".......",
" .....",
" ...",
" ..",
" ."};
/* XPM */
static char * volume_slider_bar_xpm[] = {
"95 2 2 1",
" c None",
". c #999999",
" ............................................................................................. ",
" ............................................................................................. "};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment