1 /*****************************************************************************
2 * vlcplugin.cpp: a VLC plugin for Mozilla
3 *****************************************************************************
4 * Copyright (C) 2002-2009 the VideoLAN team
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Damien Fouilleul <damienf.fouilleul@laposte.net>
9 * Jean-Paul Saman <jpsaman@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
31 #ifdef HAVE_MOZILLA_CONFIG_H
32 # include <mozilla-config.h>
35 #include "vlcplugin.h"
36 #include "control/npolibvlc.h"
40 /*****************************************************************************
41 * VlcPlugin constructor and destructor
42 *****************************************************************************/
43 VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
50 libvlc_instance(NULL),
51 libvlc_media_list(NULL),
52 libvlc_media_player(NULL),
61 ,i_width((unsigned)-1)
62 ,i_height((unsigned)-1)
71 ,p_btnFullscreen(NULL)
76 memset(&npwindow, 0, sizeof(NPWindow));
79 static bool boolValue(const char *value) {
80 return ( !strcmp(value, "1") ||
81 !strcasecmp(value, "true") ||
82 !strcasecmp(value, "yes") );
85 NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
87 /* prepare VLC command line */
88 const char *ppsz_argv[32];
92 ppsz_argv[ppsz_argc++] = "--no-plugins-cache";
95 /* locate VLC module path */
97 ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules";
98 ppsz_argv[ppsz_argc++] = "--vout=macosx";
101 DWORD i_type, i_data = MAX_PATH + 1;
102 char p_data[MAX_PATH + 1];
103 if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
104 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
106 if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
107 (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
109 if( i_type == REG_SZ )
111 strcat( p_data, "\\plugins" );
112 ppsz_argv[ppsz_argc++] = "--plugin-path";
113 ppsz_argv[ppsz_argc++] = p_data;
116 RegCloseKey( h_key );
118 ppsz_argv[ppsz_argc++] = "--no-one-instance";
120 #endif /* XP_MACOSX */
122 /* common settings */
123 ppsz_argv[ppsz_argc++] = "-vv";
124 ppsz_argv[ppsz_argc++] = "--no-stats";
125 ppsz_argv[ppsz_argc++] = "--no-media-library";
126 ppsz_argv[ppsz_argc++] = "--ignore-config";
127 ppsz_argv[ppsz_argc++] = "--intf=dummy";
128 const char *progid = NULL;
130 /* parse plugin arguments */
131 for( int i = 0; i < argc ; i++ )
133 fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]);
135 if( !strcmp( argn[i], "target" )
136 || !strcmp( argn[i], "mrl")
137 || !strcmp( argn[i], "filename")
138 || !strcmp( argn[i], "src") )
140 psz_target = argv[i];
142 else if( !strcmp( argn[i], "autoplay")
143 || !strcmp( argn[i], "autostart") )
145 b_autoplay = boolValue(argv[i]);
147 else if( !strcmp( argn[i], "fullscreen" ) )
149 if( boolValue(argv[i]) )
151 ppsz_argv[ppsz_argc++] = "--fullscreen";
155 ppsz_argv[ppsz_argc++] = "--no-fullscreen";
158 else if( !strcmp( argn[i], "mute" ) )
160 if( boolValue(argv[i]) )
162 ppsz_argv[ppsz_argc++] = "--volume=0";
165 else if( !strcmp( argn[i], "loop")
166 || !strcmp( argn[i], "autoloop") )
168 if( boolValue(argv[i]) )
170 ppsz_argv[ppsz_argc++] = "--loop";
174 ppsz_argv[ppsz_argc++] = "--no-loop";
177 else if( !strcmp( argn[i], "version")
178 || !strcmp( argn[i], "progid") )
182 else if( !strcmp( argn[i], "toolbar" ) )
184 /* FIXME: Remove this when toolbar functionality has been implemented on\
185 * MacOS X and Win32 for Firefox/Mozilla/Safari. */
187 b_toolbar = boolValue(argv[i]);
192 libvlc_exception_t ex;
193 libvlc_exception_init(&ex);
195 libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, &ex);
197 if( libvlc_exception_raised(&ex) )
199 libvlc_exception_clear(&ex);
200 return NPERR_GENERIC_ERROR;
203 libvlc_media_list = libvlc_media_list_new(libvlc_instance,&ex);
204 if( libvlc_exception_raised(&ex) )
206 libvlc_exception_clear(&ex);
207 return NPERR_GENERIC_ERROR;
211 ** fetch plugin base URL, which is the URL of the page containing the plugin
212 ** this URL is used for making absolute URL from relative URL that may be
213 ** passed as an MRL argument
217 if( NPERR_NO_ERROR == NPN_GetValue(p_browser, NPNVWindowNPObject, &plugin) )
220 ** is there a better way to get that info ?
222 static const char docLocHref[] = "document.location.href";
226 script.utf8characters = docLocHref;
227 script.utf8length = sizeof(docLocHref)-1;
229 if( NPN_Evaluate(p_browser, plugin, &script, &result) )
231 if( NPVARIANT_IS_STRING(result) )
233 NPString &location = NPVARIANT_TO_STRING(result);
235 psz_baseURL = static_cast<char*>(malloc(location.utf8length+1));
238 strncpy(psz_baseURL, location.utf8characters, location.utf8length);
239 psz_baseURL[location.utf8length] = '\0';
242 NPN_ReleaseVariantValue(&result);
244 NPN_ReleaseObject(plugin);
249 // get absolute URL from src
250 char *psz_absurl = getAbsoluteURL(psz_target);
251 psz_target = psz_absurl ? psz_absurl : strdup(psz_target);
254 /* assign plugin script root class */
256 p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();
258 return NPERR_NO_ERROR;
261 VlcPlugin::~VlcPlugin()
266 libvlc_log_close(libvlc_log, NULL);
267 if( libvlc_media_player )
268 libvlc_media_player_release( libvlc_media_player );
269 if( libvlc_media_list )
270 libvlc_media_list_release( libvlc_media_list );
271 if( libvlc_instance )
272 libvlc_release(libvlc_instance);
275 /*****************************************************************************
276 * VlcPlugin playlist replacement methods
277 *****************************************************************************/
278 void VlcPlugin::set_player_window( libvlc_exception_t *ex )
281 libvlc_media_player_set_xwindow(libvlc_media_player,
282 (libvlc_drawable_t)getWindow().window,
286 // XXX FIXME insert appropriate call here
289 libvlc_media_player_set_hwnd(libvlc_media_player,
295 int VlcPlugin::playlist_add( const char *mrl, libvlc_exception_t *ex )
298 libvlc_media_t *p_m = libvlc_media_new(libvlc_instance,mrl,ex);
299 if( libvlc_exception_raised(ex) )
302 libvlc_media_list_lock(libvlc_media_list);
303 libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
304 if( !libvlc_exception_raised(ex) )
305 item = libvlc_media_list_count(libvlc_media_list,ex)-1;
306 libvlc_media_list_unlock(libvlc_media_list);
308 libvlc_media_release(p_m);
313 int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *name,
314 int optc, const char **optv, libvlc_exception_t *ex )
316 libvlc_media_t *p_m = libvlc_media_new(libvlc_instance, mrl,ex);
318 if( libvlc_exception_raised(ex) )
321 for( int i = 0; i < optc; ++i )
323 libvlc_media_add_option_untrusted(p_m, optv[i],ex);
324 if( libvlc_exception_raised(ex) )
326 libvlc_media_release(p_m);
331 libvlc_media_list_lock(libvlc_media_list);
332 libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
333 if( !libvlc_exception_raised(ex) )
334 item = libvlc_media_list_count(libvlc_media_list,ex)-1;
335 libvlc_media_list_unlock(libvlc_media_list);
336 libvlc_media_release(p_m);
341 void VlcPlugin::playlist_play( libvlc_exception_t *ex )
343 if( libvlc_media_player||playlist_select(0,ex) )
344 libvlc_media_player_play(libvlc_media_player,ex);
347 void VlcPlugin::playlist_play_item( int idx, libvlc_exception_t *ex )
349 if( playlist_select(idx,ex) )
350 libvlc_media_player_play(libvlc_media_player,ex);
353 void VlcPlugin::playlist_stop( libvlc_exception_t *ex )
355 if( libvlc_media_player )
356 libvlc_media_player_stop(libvlc_media_player,ex);
359 bool VlcPlugin::playlist_select( int idx, libvlc_exception_t *ex )
361 libvlc_media_t *p_m = NULL;
363 libvlc_media_list_lock(libvlc_media_list);
365 int count = libvlc_media_list_count(libvlc_media_list,ex);
366 if( libvlc_exception_raised(ex) )
369 if( idx<0||idx>=count )
372 playlist_index = idx;
374 p_m = libvlc_media_list_item_at_index(libvlc_media_list,playlist_index,ex);
375 libvlc_media_list_unlock(libvlc_media_list);
377 if( libvlc_exception_raised(ex) )
380 if( libvlc_media_player )
382 libvlc_media_player_release( libvlc_media_player );
383 libvlc_media_player = NULL;
386 libvlc_media_player = libvlc_media_player_new_from_media(p_m,ex);
387 if( libvlc_media_player )
388 set_player_window(ex);
390 libvlc_media_release( p_m );
391 return !libvlc_exception_raised(ex);
394 libvlc_media_list_unlock(libvlc_media_list);
398 void VlcPlugin::playlist_next( libvlc_exception_t *ex )
400 if( playlist_select(playlist_index+1,ex) )
401 libvlc_media_player_play(libvlc_media_player,ex);
404 void VlcPlugin::playlist_prev( libvlc_exception_t *ex )
406 if( playlist_select(playlist_index-1,ex) )
407 libvlc_media_player_play(libvlc_media_player,ex);
410 void VlcPlugin::playlist_pause( libvlc_exception_t *ex )
412 if( libvlc_media_player )
413 libvlc_media_player_pause(libvlc_media_player,ex);
416 void VlcPlugin::playlist_delete_item( int idx, libvlc_exception_t *ex )
418 libvlc_media_list_lock(libvlc_media_list);
419 libvlc_media_list_remove_index(libvlc_media_list,idx,ex);
420 libvlc_media_list_unlock(libvlc_media_list);
423 void VlcPlugin::playlist_clear( libvlc_exception_t *ex )
425 if( libvlc_media_list )
426 libvlc_media_list_release(libvlc_media_list);
427 libvlc_media_list = libvlc_media_list_new(getVLC(),ex);
430 int VlcPlugin::playlist_count( libvlc_exception_t *ex )
433 libvlc_media_list_lock(libvlc_media_list);
434 items_count = libvlc_media_list_count(libvlc_media_list,ex);
435 libvlc_media_list_unlock(libvlc_media_list);
439 int VlcPlugin::playlist_isplaying( libvlc_exception_t *ex )
442 if( libvlc_media_player )
443 libvlc_media_player_is_playing( libvlc_media_player, ex );
447 void VlcPlugin::toggle_fullscreen( libvlc_exception_t *ex )
449 if( playlist_isplaying(ex) )
450 libvlc_toggle_fullscreen(libvlc_media_player,ex);
453 void VlcPlugin::set_fullscreen( int yes, libvlc_exception_t *ex )
455 if( playlist_isplaying(ex) )
456 libvlc_set_fullscreen(libvlc_media_player,yes,ex);
459 int VlcPlugin::get_fullscreen( libvlc_exception_t *ex )
462 if( playlist_isplaying(ex) )
463 r = libvlc_get_fullscreen(libvlc_media_player,ex);
467 int VlcPlugin::player_has_vout( libvlc_exception_t *ex )
470 if( playlist_isplaying(ex) )
471 r = libvlc_media_player_has_vout(libvlc_media_player, ex);
476 /*****************************************************************************
478 *****************************************************************************/
480 char *VlcPlugin::getAbsoluteURL(const char *url)
484 // check whether URL is already absolute
485 const char *end=strchr(url, ':');
486 if( (NULL != end) && (end != url) )
488 // validate protocol header
489 const char *start = url;
494 while( start != end )
501 || ('/' == c)) ) /* VLC uses / to allow user to specify a demuxer */
502 // not valid protocol header, assume relative URL
506 /* we have a protocol header, therefore URL is absolute */
509 // not a valid protocol header, assume relative URL
516 size_t baseLen = strlen(psz_baseURL);
517 char *href = static_cast<char*>(malloc(baseLen+strlen(url)+1));
520 /* prepend base URL */
521 strcpy(href, psz_baseURL);
524 ** relative url could be empty,
525 ** in which case return base URL
531 ** locate pathname part of base URL
534 /* skip over protocol part */
535 char *pathstart = strchr(href, ':');
539 if( '/' == *(++pathstart) )
541 if( '/' == *(++pathstart) )
546 /* skip over host part */
547 pathstart = strchr(pathstart, '/');
548 pathend = href+baseLen;
551 // no path, add a / past end of url (over '\0')
558 /* baseURL is just a UNIX path */
561 /* baseURL is not an absolute path */
566 pathend = href+baseLen;
569 /* relative URL made of an absolute path ? */
572 /* replace path completely */
573 strcpy(pathstart, url);
577 /* find last path component and replace it */
578 while( '/' != *pathend)
582 ** if relative url path starts with one or more '../',
583 ** factor them out of href so that we return a
586 while( pathend != pathstart )
594 /* relative url is just '.' */
600 /* relative url starts with './' */
609 /* relative url is '..' */
615 /* relative url starts with '../' */
623 while( '/' != *pathend );
625 /* skip over '/' separator */
627 /* concatenate remaining base URL and relative URL */
628 strcpy(pathend, url);
637 int VlcPlugin::setSize(unsigned width, unsigned height)
639 int diff = (width != i_width) || (height != i_height);
648 #define BTN_SPACE ((unsigned int)4)
649 void VlcPlugin::showToolbar()
651 const NPWindow& window = getWindow();
652 Window control = getControlWindow();
653 Window video = getVideoWindow();
654 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
655 unsigned int i_height = 0, i_width = BTN_SPACE;
659 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm",
660 &p_btnPlay, NULL, NULL);
663 i_height = __MAX( i_height, p_btnPlay->height );
666 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm",
667 &p_btnPause, NULL, NULL);
670 i_height = __MAX( i_height, p_btnPause->height );
672 i_width += __MAX( p_btnPause->width, p_btnPlay->width );
675 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm",
676 &p_btnStop, NULL, NULL );
679 i_height = __MAX( i_height, p_btnStop->height );
680 i_width += BTN_SPACE + p_btnStop->width;
683 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm",
684 &p_timeline, NULL, NULL);
687 i_height = __MAX( i_height, p_timeline->height );
688 i_width += BTN_SPACE + p_timeline->width;
691 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm",
692 &p_btnTime, NULL, NULL);
695 i_height = __MAX( i_height, p_btnTime->height );
696 i_width += BTN_SPACE + p_btnTime->width;
698 if( !p_btnFullscreen )
699 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm",
700 &p_btnFullscreen, NULL, NULL);
701 if( p_btnFullscreen )
703 i_height = __MAX( i_height, p_btnFullscreen->height );
704 i_width += BTN_SPACE + p_btnFullscreen->width;
707 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm",
708 &p_btnMute, NULL, NULL);
711 i_height = __MAX( i_height, p_btnMute->height );
714 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm",
715 &p_btnUnmute, NULL, NULL);
718 i_height = __MAX( i_height, p_btnUnmute->height );
720 i_width += BTN_SPACE + __MAX( p_btnUnmute->width, p_btnMute->width );
722 setToolbarSize( i_width, i_height );
724 if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline ||
725 !p_btnTime || !p_btnFullscreen || !p_btnMute || !p_btnUnmute )
726 fprintf(stderr, "Error: some button images not found in %s\n", DATA_PATH );
728 /* reset panels position and size */
729 /* XXX use i_width */
730 XResizeWindow( p_display, video, window.width, window.height - i_height);
731 XMoveWindow( p_display, control, 0, window.height - i_height );
732 XResizeWindow( p_display, control, window.width, i_height -1);
734 b_toolbar = 1; /* says toolbar is now shown */
738 void VlcPlugin::hideToolbar()
740 const NPWindow& window = getWindow();
741 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
742 Window control = getControlWindow();
743 Window video = getVideoWindow();
745 i_tb_width = i_tb_height = 0;
747 if( p_btnPlay ) XDestroyImage( p_btnPlay );
748 if( p_btnPause ) XDestroyImage( p_btnPause );
749 if( p_btnStop ) XDestroyImage( p_btnStop );
750 if( p_timeline ) XDestroyImage( p_timeline );
751 if( p_btnTime ) XDestroyImage( p_btnTime );
752 if( p_btnFullscreen ) XDestroyImage( p_btnFullscreen );
753 if( p_btnMute ) XDestroyImage( p_btnMute );
754 if( p_btnUnmute ) XDestroyImage( p_btnUnmute );
761 p_btnFullscreen = NULL;
765 /* reset panels position and size */
766 /* XXX use i_width */
767 XResizeWindow( p_display, video, window.width, window.height );
768 XMoveWindow( p_display, control, 0, window.height-1 );
769 XResizeWindow( p_display, control, window.width, 1 );
771 b_toolbar = 0; /* says toolbar is now hidden */
775 void VlcPlugin::redrawToolbar()
777 libvlc_exception_t ex;
780 unsigned int dst_x, dst_y;
783 unsigned int i_tb_width, i_tb_height;
785 /* This method does nothing if toolbar is hidden. */
789 const NPWindow& window = getWindow();
790 Window control = getControlWindow();
791 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
793 getToolbarSize( &i_tb_width, &i_tb_height );
795 libvlc_exception_init( &ex );
798 b_mute = libvlc_audio_get_mute( getVLC(), &ex );
799 libvlc_exception_clear( &ex );
801 gcv.foreground = BlackPixel( p_display, 0 );
802 gc = XCreateGC( p_display, control, GCForeground, &gcv );
804 XFillRectangle( p_display, control, gc,
805 0, 0, window.width, i_tb_height );
806 gcv.foreground = WhitePixel( p_display, 0 );
807 XChangeGC( p_display, gc, GCForeground, &gcv );
811 dst_y = i_tb_height >> 1; /* baseline = vertical middle */
813 if( p_btnPause && (is_playing == 1) )
815 XPutImage( p_display, control, gc, p_btnPause, 0, 0, dst_x,
816 dst_y - (p_btnPause->height >> 1),
817 p_btnPause->width, p_btnPause->height );
818 dst_x += BTN_SPACE + p_btnPause->width;
822 XPutImage( p_display, control, gc, p_btnPlay, 0, 0, dst_x,
823 dst_y - (p_btnPlay->height >> 1),
824 p_btnPlay->width, p_btnPlay->height );
825 dst_x += BTN_SPACE + p_btnPlay->width;
829 XPutImage( p_display, control, gc, p_btnStop, 0, 0, dst_x,
830 dst_y - (p_btnStop->height >> 1),
831 p_btnStop->width, p_btnStop->height );
833 dst_x += BTN_SPACE + ( p_btnStop ? p_btnStop->width : 0 );
835 if( p_btnFullscreen )
836 XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, dst_x,
837 dst_y - (p_btnFullscreen->height >> 1),
838 p_btnFullscreen->width, p_btnFullscreen->height );
840 dst_x += BTN_SPACE + ( p_btnFullscreen ? p_btnFullscreen->width : 0 );
842 if( p_btnUnmute && b_mute )
844 XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, dst_x,
845 dst_y - (p_btnUnmute->height >> 1),
846 p_btnUnmute->width, p_btnUnmute->height );
848 dst_x += BTN_SPACE + ( p_btnUnmute ? p_btnUnmute->width : 0 );
852 XPutImage( p_display, control, gc, p_btnMute, 0, 0, dst_x,
853 dst_y - (p_btnMute->height >> 1),
854 p_btnMute->width, p_btnMute->height );
856 dst_x += BTN_SPACE + ( p_btnMute ? p_btnMute->width : 0 );
860 XPutImage( p_display, control, gc, p_timeline, 0, 0, dst_x,
861 dst_y - (p_timeline->height >> 1),
862 (window.width-(dst_x+BTN_SPACE)), p_timeline->height );
866 /* get movie position in % */
867 if( playlist_isplaying(&ex) )
869 i_last_position = (int)((window.width-(dst_x+BTN_SPACE))*
870 libvlc_media_player_get_position(libvlc_media_player,&ex));
872 libvlc_exception_clear( &ex );
875 XPutImage( p_display, control, gc, p_btnTime,
876 0, 0, (dst_x+i_last_position),
877 dst_y - (p_btnTime->height >> 1),
878 p_btnTime->width, p_btnTime->height );
880 XFreeGC( p_display, gc );
883 vlc_toolbar_clicked_t VlcPlugin::getToolbarButtonClicked( int i_xpos, int i_ypos )
885 unsigned int i_dest = BTN_SPACE;//(i_tb_height >> 1);
888 libvlc_exception_t ex;
890 fprintf( stderr, "ToolbarButtonClicked:: "
891 "trying to match (%d,%d) (%d,%d)\n",
892 i_xpos, i_ypos, i_tb_height, i_tb_width );
894 if( i_ypos >= i_tb_width )
895 return clicked_Unknown;
897 /* Note: the order of testing is dependend on the original
898 * drawing positions of the icon buttons. Buttons are tested
903 libvlc_exception_init( &ex );
904 is_playing = playlist_isplaying( &ex );
905 libvlc_exception_clear( &ex );
908 b_mute = libvlc_audio_get_mute( getVLC(), &ex );
909 libvlc_exception_clear( &ex );
911 /* is Pause of Play button clicked */
912 if( (is_playing != 1) &&
913 (i_xpos >= (BTN_SPACE>>1)) &&
914 (i_xpos <= i_dest + p_btnPlay->width + (BTN_SPACE>>1)) )
916 else if( (i_xpos >= (BTN_SPACE>>1)) &&
917 (i_xpos <= i_dest + p_btnPause->width) )
918 return clicked_Pause;
920 /* is Stop button clicked */
921 if( is_playing != 1 )
922 i_dest += (p_btnPlay->width + (BTN_SPACE>>1));
924 i_dest += (p_btnPause->width + (BTN_SPACE>>1));
926 if( (i_xpos >= i_dest) &&
927 (i_xpos <= i_dest + p_btnStop->width + (BTN_SPACE>>1)) )
930 /* is Fullscreen button clicked */
931 i_dest += (p_btnStop->width + (BTN_SPACE>>1));
932 if( (i_xpos >= i_dest) &&
933 (i_xpos <= i_dest + p_btnFullscreen->width + (BTN_SPACE>>1)) )
934 return clicked_Fullscreen;
936 /* is Mute or Unmute button clicked */
937 i_dest += (p_btnFullscreen->width + (BTN_SPACE>>1));
938 if( !b_mute && (i_xpos >= i_dest) &&
939 (i_xpos <= i_dest + p_btnMute->width + (BTN_SPACE>>1)) )
941 else if( (i_xpos >= i_dest) &&
942 (i_xpos <= i_dest + p_btnUnmute->width + (BTN_SPACE>>1)) )
943 return clicked_Unmute;
945 /* is timeline clicked */
947 i_dest += (p_btnMute->width + (BTN_SPACE>>1));
949 i_dest += (p_btnUnmute->width + (BTN_SPACE>>1));
950 if( (i_xpos >= i_dest) &&
951 (i_xpos <= i_dest + p_timeline->width + (BTN_SPACE>>1)) )
952 return clicked_timeline;
954 /* is time button clicked */
955 i_dest += (p_timeline->width + (BTN_SPACE>>1));
956 if( (i_xpos >= i_dest) &&
957 (i_xpos <= i_dest + p_btnTime->width + (BTN_SPACE>>1)) )
960 return clicked_Unknown;