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));
77 memset(&npvideo, 0, sizeof(Window));
78 memset(&npcontrol, 0, sizeof(Window));
81 static bool boolValue(const char *value) {
82 return ( !strcmp(value, "1") ||
83 !strcasecmp(value, "true") ||
84 !strcasecmp(value, "yes") );
87 NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
89 /* prepare VLC command line */
90 const char *ppsz_argv[32];
94 ppsz_argv[ppsz_argc++] = "--no-plugins-cache";
97 /* locate VLC module path */
99 ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules";
100 ppsz_argv[ppsz_argc++] = "--vout=macosx";
101 #elif defined(XP_WIN)
103 DWORD i_type, i_data = MAX_PATH + 1;
104 char p_data[MAX_PATH + 1];
105 if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
106 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
108 if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
109 (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
111 if( i_type == REG_SZ )
113 strcat( p_data, "\\plugins" );
114 ppsz_argv[ppsz_argc++] = "--plugin-path";
115 ppsz_argv[ppsz_argc++] = p_data;
118 RegCloseKey( h_key );
120 ppsz_argv[ppsz_argc++] = "--no-one-instance";
122 #endif /* XP_MACOSX */
124 /* common settings */
125 ppsz_argv[ppsz_argc++] = "-vv";
126 ppsz_argv[ppsz_argc++] = "--no-stats";
127 ppsz_argv[ppsz_argc++] = "--no-media-library";
128 ppsz_argv[ppsz_argc++] = "--ignore-config";
129 ppsz_argv[ppsz_argc++] = "--intf=dummy";
130 ppsz_argv[ppsz_argc++] = "--no-video-title-show";
132 const char *progid = NULL;
134 /* parse plugin arguments */
135 for( int i = 0; i < argc ; i++ )
137 fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]);
139 if( !strcmp( argn[i], "target" )
140 || !strcmp( argn[i], "mrl")
141 || !strcmp( argn[i], "filename")
142 || !strcmp( argn[i], "src") )
144 psz_target = argv[i];
146 else if( !strcmp( argn[i], "autoplay")
147 || !strcmp( argn[i], "autostart") )
149 b_autoplay = boolValue(argv[i]);
151 else if( !strcmp( argn[i], "fullscreen" ) )
153 if( boolValue(argv[i]) )
155 ppsz_argv[ppsz_argc++] = "--fullscreen";
159 ppsz_argv[ppsz_argc++] = "--no-fullscreen";
162 else if( !strcmp( argn[i], "mute" ) )
164 if( boolValue(argv[i]) )
166 ppsz_argv[ppsz_argc++] = "--volume=0";
169 else if( !strcmp( argn[i], "loop")
170 || !strcmp( argn[i], "autoloop") )
172 if( boolValue(argv[i]) )
174 ppsz_argv[ppsz_argc++] = "--loop";
178 ppsz_argv[ppsz_argc++] = "--no-loop";
181 else if( !strcmp( argn[i], "version")
182 || !strcmp( argn[i], "progid") )
186 else if( !strcmp( argn[i], "toolbar" ) )
188 /* FIXME: Remove this when toolbar functionality has been implemented on\
189 * MacOS X and Win32 for Firefox/Mozilla/Safari. */
191 b_toolbar = boolValue(argv[i]);
196 libvlc_exception_t ex;
197 libvlc_exception_init(&ex);
199 libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, &ex);
201 if( libvlc_exception_raised(&ex) )
203 libvlc_exception_clear(&ex);
204 return NPERR_GENERIC_ERROR;
207 libvlc_media_list = libvlc_media_list_new(libvlc_instance,&ex);
208 if( libvlc_exception_raised(&ex) )
210 libvlc_exception_clear(&ex);
211 return NPERR_GENERIC_ERROR;
215 ** fetch plugin base URL, which is the URL of the page containing the plugin
216 ** this URL is used for making absolute URL from relative URL that may be
217 ** passed as an MRL argument
221 if( NPERR_NO_ERROR == NPN_GetValue(p_browser, NPNVWindowNPObject, &plugin) )
224 ** is there a better way to get that info ?
226 static const char docLocHref[] = "document.location.href";
230 script.utf8characters = docLocHref;
231 script.utf8length = sizeof(docLocHref)-1;
233 if( NPN_Evaluate(p_browser, plugin, &script, &result) )
235 if( NPVARIANT_IS_STRING(result) )
237 NPString &location = NPVARIANT_TO_STRING(result);
239 psz_baseURL = static_cast<char*>(malloc(location.utf8length+1));
242 strncpy(psz_baseURL, location.utf8characters, location.utf8length);
243 psz_baseURL[location.utf8length] = '\0';
246 NPN_ReleaseVariantValue(&result);
248 NPN_ReleaseObject(plugin);
253 // get absolute URL from src
254 char *psz_absurl = getAbsoluteURL(psz_target);
255 psz_target = psz_absurl ? psz_absurl : strdup(psz_target);
258 /* assign plugin script root class */
260 p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();
262 return NPERR_NO_ERROR;
265 VlcPlugin::~VlcPlugin()
270 libvlc_log_close(libvlc_log, NULL);
271 if( libvlc_media_player )
272 libvlc_media_player_release( libvlc_media_player );
273 if( libvlc_media_list )
274 libvlc_media_list_release( libvlc_media_list );
275 if( libvlc_instance )
276 libvlc_release(libvlc_instance);
279 /*****************************************************************************
280 * VlcPlugin playlist replacement methods
281 *****************************************************************************/
282 void VlcPlugin::set_player_window( libvlc_exception_t *ex )
285 libvlc_media_player_set_xwindow(libvlc_media_player,
286 (libvlc_drawable_t)getVideoWindow(),
290 // XXX FIXME insert appropriate call here
293 libvlc_media_player_set_hwnd(libvlc_media_player,
299 int VlcPlugin::playlist_add( const char *mrl, libvlc_exception_t *ex )
302 libvlc_media_t *p_m = libvlc_media_new(libvlc_instance,mrl,ex);
303 if( libvlc_exception_raised(ex) )
306 libvlc_media_list_lock(libvlc_media_list);
307 libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
308 if( !libvlc_exception_raised(ex) )
309 item = libvlc_media_list_count(libvlc_media_list,ex)-1;
310 libvlc_media_list_unlock(libvlc_media_list);
312 libvlc_media_release(p_m);
317 int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *name,
318 int optc, const char **optv, libvlc_exception_t *ex )
320 libvlc_media_t *p_m = libvlc_media_new(libvlc_instance, mrl,ex);
322 if( libvlc_exception_raised(ex) )
325 for( int i = 0; i < optc; ++i )
327 libvlc_media_add_option_untrusted(p_m, optv[i],ex);
328 if( libvlc_exception_raised(ex) )
330 libvlc_media_release(p_m);
335 libvlc_media_list_lock(libvlc_media_list);
336 libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
337 if( !libvlc_exception_raised(ex) )
338 item = libvlc_media_list_count(libvlc_media_list,ex)-1;
339 libvlc_media_list_unlock(libvlc_media_list);
340 libvlc_media_release(p_m);
345 void VlcPlugin::playlist_play( libvlc_exception_t *ex )
347 if( libvlc_media_player||playlist_select(0,ex) )
348 libvlc_media_player_play(libvlc_media_player,ex);
351 void VlcPlugin::playlist_play_item( int idx, libvlc_exception_t *ex )
353 if( playlist_select(idx,ex) )
354 libvlc_media_player_play(libvlc_media_player,ex);
357 void VlcPlugin::playlist_stop( libvlc_exception_t *ex )
359 if( libvlc_media_player )
360 libvlc_media_player_stop(libvlc_media_player,ex);
363 bool VlcPlugin::playlist_select( int idx, libvlc_exception_t *ex )
365 libvlc_media_t *p_m = NULL;
367 libvlc_media_list_lock(libvlc_media_list);
369 int count = libvlc_media_list_count(libvlc_media_list,ex);
370 if( libvlc_exception_raised(ex) )
373 if( idx<0||idx>=count )
376 playlist_index = idx;
378 p_m = libvlc_media_list_item_at_index(libvlc_media_list,playlist_index,ex);
379 libvlc_media_list_unlock(libvlc_media_list);
381 if( libvlc_exception_raised(ex) )
384 if( libvlc_media_player )
386 libvlc_media_player_release( libvlc_media_player );
387 libvlc_media_player = NULL;
390 libvlc_media_player = libvlc_media_player_new_from_media(p_m,ex);
391 if( libvlc_media_player )
392 set_player_window(ex);
394 libvlc_media_release( p_m );
395 return !libvlc_exception_raised(ex);
398 libvlc_media_list_unlock(libvlc_media_list);
402 void VlcPlugin::playlist_next( libvlc_exception_t *ex )
404 if( playlist_select(playlist_index+1,ex) )
405 libvlc_media_player_play(libvlc_media_player,ex);
408 void VlcPlugin::playlist_prev( libvlc_exception_t *ex )
410 if( playlist_select(playlist_index-1,ex) )
411 libvlc_media_player_play(libvlc_media_player,ex);
414 void VlcPlugin::playlist_pause( libvlc_exception_t *ex )
416 if( libvlc_media_player )
417 libvlc_media_player_pause(libvlc_media_player,ex);
420 void VlcPlugin::playlist_delete_item( int idx, libvlc_exception_t *ex )
422 libvlc_media_list_lock(libvlc_media_list);
423 libvlc_media_list_remove_index(libvlc_media_list,idx,ex);
424 libvlc_media_list_unlock(libvlc_media_list);
427 void VlcPlugin::playlist_clear( libvlc_exception_t *ex )
429 if( libvlc_media_list )
430 libvlc_media_list_release(libvlc_media_list);
431 libvlc_media_list = libvlc_media_list_new(getVLC(),ex);
434 int VlcPlugin::playlist_count( libvlc_exception_t *ex )
437 libvlc_media_list_lock(libvlc_media_list);
438 items_count = libvlc_media_list_count(libvlc_media_list,ex);
439 libvlc_media_list_unlock(libvlc_media_list);
443 int VlcPlugin::playlist_isplaying( libvlc_exception_t *ex )
446 if( libvlc_media_player )
447 is_playing = libvlc_media_player_is_playing( libvlc_media_player, ex );
451 void VlcPlugin::toggle_fullscreen( libvlc_exception_t *ex )
453 if( playlist_isplaying(ex) )
454 libvlc_toggle_fullscreen(libvlc_media_player,ex);
457 void VlcPlugin::set_fullscreen( int yes, libvlc_exception_t *ex )
459 if( playlist_isplaying(ex) )
460 libvlc_set_fullscreen(libvlc_media_player,yes,ex);
463 int VlcPlugin::get_fullscreen( libvlc_exception_t *ex )
466 if( playlist_isplaying(ex) )
467 r = libvlc_get_fullscreen(libvlc_media_player,ex);
471 int VlcPlugin::player_has_vout( libvlc_exception_t *ex )
474 if( playlist_isplaying(ex) )
475 r = libvlc_media_player_has_vout(libvlc_media_player, ex);
479 /*****************************************************************************
481 *****************************************************************************/
483 char *VlcPlugin::getAbsoluteURL(const char *url)
487 // check whether URL is already absolute
488 const char *end=strchr(url, ':');
489 if( (NULL != end) && (end != url) )
491 // validate protocol header
492 const char *start = url;
497 while( start != end )
504 || ('/' == c)) ) /* VLC uses / to allow user to specify a demuxer */
505 // not valid protocol header, assume relative URL
509 /* we have a protocol header, therefore URL is absolute */
512 // not a valid protocol header, assume relative URL
519 size_t baseLen = strlen(psz_baseURL);
520 char *href = static_cast<char*>(malloc(baseLen+strlen(url)+1));
523 /* prepend base URL */
524 strcpy(href, psz_baseURL);
527 ** relative url could be empty,
528 ** in which case return base URL
534 ** locate pathname part of base URL
537 /* skip over protocol part */
538 char *pathstart = strchr(href, ':');
542 if( '/' == *(++pathstart) )
544 if( '/' == *(++pathstart) )
549 /* skip over host part */
550 pathstart = strchr(pathstart, '/');
551 pathend = href+baseLen;
554 // no path, add a / past end of url (over '\0')
561 /* baseURL is just a UNIX path */
564 /* baseURL is not an absolute path */
569 pathend = href+baseLen;
572 /* relative URL made of an absolute path ? */
575 /* replace path completely */
576 strcpy(pathstart, url);
580 /* find last path component and replace it */
581 while( '/' != *pathend)
585 ** if relative url path starts with one or more '../',
586 ** factor them out of href so that we return a
589 while( pathend != pathstart )
597 /* relative url is just '.' */
603 /* relative url starts with './' */
612 /* relative url is '..' */
618 /* relative url starts with '../' */
626 while( '/' != *pathend );
628 /* skip over '/' separator */
630 /* concatenate remaining base URL and relative URL */
631 strcpy(pathend, url);
640 int VlcPlugin::setSize(unsigned width, unsigned height)
642 int diff = (width != i_width) || (height != i_height);
651 #define BTN_SPACE ((unsigned int)4)
652 void VlcPlugin::showToolbar()
654 const NPWindow& window = getWindow();
655 Window control = getControlWindow();
656 Window video = getVideoWindow();
657 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
658 unsigned int i_height = 0, i_width = BTN_SPACE;
662 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm",
663 &p_btnPlay, NULL, NULL);
666 i_height = __MAX( i_height, p_btnPlay->height );
669 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm",
670 &p_btnPause, NULL, NULL);
673 i_height = __MAX( i_height, p_btnPause->height );
675 i_width += __MAX( p_btnPause->width, p_btnPlay->width );
678 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm",
679 &p_btnStop, NULL, NULL );
682 i_height = __MAX( i_height, p_btnStop->height );
683 i_width += BTN_SPACE + p_btnStop->width;
686 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm",
687 &p_timeline, NULL, NULL);
690 i_height = __MAX( i_height, p_timeline->height );
691 i_width += BTN_SPACE + p_timeline->width;
694 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm",
695 &p_btnTime, NULL, NULL);
698 i_height = __MAX( i_height, p_btnTime->height );
699 i_width += BTN_SPACE + p_btnTime->width;
701 if( !p_btnFullscreen )
702 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm",
703 &p_btnFullscreen, NULL, NULL);
704 if( p_btnFullscreen )
706 i_height = __MAX( i_height, p_btnFullscreen->height );
707 i_width += BTN_SPACE + p_btnFullscreen->width;
710 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm",
711 &p_btnMute, NULL, NULL);
714 i_height = __MAX( i_height, p_btnMute->height );
717 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm",
718 &p_btnUnmute, NULL, NULL);
721 i_height = __MAX( i_height, p_btnUnmute->height );
723 i_width += BTN_SPACE + __MAX( p_btnUnmute->width, p_btnMute->width );
725 setToolbarSize( i_width, i_height );
727 if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline ||
728 !p_btnTime || !p_btnFullscreen || !p_btnMute || !p_btnUnmute )
729 fprintf(stderr, "Error: some button images not found in %s\n", DATA_PATH );
731 /* reset panels position and size */
732 /* XXX use i_width */
733 XResizeWindow( p_display, video, window.width, window.height - i_height);
734 XMoveWindow( p_display, control, 0, window.height - i_height );
735 XResizeWindow( p_display, control, window.width, i_height -1);
737 b_toolbar = 1; /* says toolbar is now shown */
741 void VlcPlugin::hideToolbar()
743 const NPWindow& window = getWindow();
744 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
745 Window control = getControlWindow();
746 Window video = getVideoWindow();
748 i_tb_width = i_tb_height = 0;
750 if( p_btnPlay ) XDestroyImage( p_btnPlay );
751 if( p_btnPause ) XDestroyImage( p_btnPause );
752 if( p_btnStop ) XDestroyImage( p_btnStop );
753 if( p_timeline ) XDestroyImage( p_timeline );
754 if( p_btnTime ) XDestroyImage( p_btnTime );
755 if( p_btnFullscreen ) XDestroyImage( p_btnFullscreen );
756 if( p_btnMute ) XDestroyImage( p_btnMute );
757 if( p_btnUnmute ) XDestroyImage( p_btnUnmute );
764 p_btnFullscreen = NULL;
768 /* reset panels position and size */
769 /* XXX use i_width */
770 XResizeWindow( p_display, video, window.width, window.height );
771 XMoveWindow( p_display, control, 0, window.height-1 );
772 XResizeWindow( p_display, control, window.width, 1 );
774 b_toolbar = 0; /* says toolbar is now hidden */
778 void VlcPlugin::redrawToolbar()
780 libvlc_exception_t ex;
783 unsigned int dst_x, dst_y;
786 unsigned int i_tb_width, i_tb_height;
788 /* This method does nothing if toolbar is hidden. */
792 const NPWindow& window = getWindow();
793 Window control = getControlWindow();
794 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
796 getToolbarSize( &i_tb_width, &i_tb_height );
798 libvlc_exception_init( &ex );
801 b_mute = libvlc_audio_get_mute( getVLC(), &ex );
802 libvlc_exception_clear( &ex );
804 gcv.foreground = BlackPixel( p_display, 0 );
805 gc = XCreateGC( p_display, control, GCForeground, &gcv );
807 XFillRectangle( p_display, control, gc,
808 0, 0, window.width, i_tb_height );
809 gcv.foreground = WhitePixel( p_display, 0 );
810 XChangeGC( p_display, gc, GCForeground, &gcv );
814 dst_y = i_tb_height >> 1; /* baseline = vertical middle */
816 if( p_btnPause && (is_playing == 1) )
818 XPutImage( p_display, control, gc, p_btnPause, 0, 0, dst_x,
819 dst_y - (p_btnPause->height >> 1),
820 p_btnPause->width, p_btnPause->height );
821 dst_x += BTN_SPACE + p_btnPause->width;
825 XPutImage( p_display, control, gc, p_btnPlay, 0, 0, dst_x,
826 dst_y - (p_btnPlay->height >> 1),
827 p_btnPlay->width, p_btnPlay->height );
828 dst_x += BTN_SPACE + p_btnPlay->width;
832 XPutImage( p_display, control, gc, p_btnStop, 0, 0, dst_x,
833 dst_y - (p_btnStop->height >> 1),
834 p_btnStop->width, p_btnStop->height );
836 dst_x += BTN_SPACE + ( p_btnStop ? p_btnStop->width : 0 );
838 if( p_btnFullscreen )
839 XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, dst_x,
840 dst_y - (p_btnFullscreen->height >> 1),
841 p_btnFullscreen->width, p_btnFullscreen->height );
843 dst_x += BTN_SPACE + ( p_btnFullscreen ? p_btnFullscreen->width : 0 );
845 if( p_btnUnmute && b_mute )
847 XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, dst_x,
848 dst_y - (p_btnUnmute->height >> 1),
849 p_btnUnmute->width, p_btnUnmute->height );
851 dst_x += BTN_SPACE + ( p_btnUnmute ? p_btnUnmute->width : 0 );
855 XPutImage( p_display, control, gc, p_btnMute, 0, 0, dst_x,
856 dst_y - (p_btnMute->height >> 1),
857 p_btnMute->width, p_btnMute->height );
859 dst_x += BTN_SPACE + ( p_btnMute ? p_btnMute->width : 0 );
863 XPutImage( p_display, control, gc, p_timeline, 0, 0, dst_x,
864 dst_y - (p_timeline->height >> 1),
865 (window.width-(dst_x+BTN_SPACE)), p_timeline->height );
867 /* get movie position in % */
868 if( playlist_isplaying(&ex) )
870 i_last_position = (int)((window.width-(dst_x+BTN_SPACE))*
871 libvlc_media_player_get_position(libvlc_media_player,&ex));
873 libvlc_exception_clear( &ex );
876 XPutImage( p_display, control, gc, p_btnTime,
877 0, 0, (dst_x+i_last_position),
878 dst_y - (p_btnTime->height >> 1),
879 p_btnTime->width, p_btnTime->height );
881 XFreeGC( p_display, gc );
884 vlc_toolbar_clicked_t VlcPlugin::getToolbarButtonClicked( int i_xpos, int i_ypos )
886 unsigned int i_dest = BTN_SPACE;
889 libvlc_exception_t ex;
892 fprintf( stderr, "ToolbarButtonClicked:: "
893 "trying to match (%d,%d) (%d,%d)\n",
894 i_xpos, i_ypos, i_tb_height, i_tb_width );
896 if( i_ypos >= i_tb_width )
897 return clicked_Unknown;
899 /* Note: the order of testing is dependend on the original
900 * drawing positions of the icon buttons. Buttons are tested
905 libvlc_exception_init( &ex );
906 is_playing = playlist_isplaying( &ex );
907 libvlc_exception_clear( &ex );
910 b_mute = libvlc_audio_get_mute( getVLC(), &ex );
911 libvlc_exception_clear( &ex );
913 /* is Pause of Play button clicked */
914 if( (is_playing != 1) &&
915 (i_xpos >= (BTN_SPACE>>1)) &&
916 (i_xpos <= i_dest + p_btnPlay->width + (BTN_SPACE>>1)) )
918 else if( (i_xpos >= (BTN_SPACE>>1)) &&
919 (i_xpos <= i_dest + p_btnPause->width) )
920 return clicked_Pause;
922 /* is Stop button clicked */
923 if( is_playing != 1 )
924 i_dest += (p_btnPlay->width + (BTN_SPACE>>1));
926 i_dest += (p_btnPause->width + (BTN_SPACE>>1));
928 if( (i_xpos >= i_dest) &&
929 (i_xpos <= i_dest + p_btnStop->width + (BTN_SPACE>>1)) )
932 /* is Fullscreen button clicked */
933 i_dest += (p_btnStop->width + (BTN_SPACE>>1));
934 if( (i_xpos >= i_dest) &&
935 (i_xpos <= i_dest + p_btnFullscreen->width + (BTN_SPACE>>1)) )
936 return clicked_Fullscreen;
938 /* is Mute or Unmute button clicked */
939 i_dest += (p_btnFullscreen->width + (BTN_SPACE>>1));
940 if( !b_mute && (i_xpos >= i_dest) &&
941 (i_xpos <= i_dest + p_btnMute->width + (BTN_SPACE>>1)) )
943 else if( (i_xpos >= i_dest) &&
944 (i_xpos <= i_dest + p_btnUnmute->width + (BTN_SPACE>>1)) )
945 return clicked_Unmute;
947 /* is timeline clicked */
949 i_dest += (p_btnMute->width + (BTN_SPACE>>1));
951 i_dest += (p_btnUnmute->width + (BTN_SPACE>>1));
952 if( (i_xpos >= i_dest) &&
953 (i_xpos <= i_dest + p_timeline->width + (BTN_SPACE>>1)) )
954 return clicked_timeline;
956 /* is time button clicked */
957 i_dest += (p_timeline->width + (BTN_SPACE>>1));
958 if( (i_xpos >= i_dest) &&
959 (i_xpos <= i_dest + p_btnTime->width + (BTN_SPACE>>1)) )
962 return clicked_Unknown;