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 const char *progid = NULL;
132 /* parse plugin arguments */
133 for( int i = 0; i < argc ; i++ )
135 fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]);
137 if( !strcmp( argn[i], "target" )
138 || !strcmp( argn[i], "mrl")
139 || !strcmp( argn[i], "filename")
140 || !strcmp( argn[i], "src") )
142 psz_target = argv[i];
144 else if( !strcmp( argn[i], "autoplay")
145 || !strcmp( argn[i], "autostart") )
147 b_autoplay = boolValue(argv[i]);
149 else if( !strcmp( argn[i], "fullscreen" ) )
151 if( boolValue(argv[i]) )
153 ppsz_argv[ppsz_argc++] = "--fullscreen";
157 ppsz_argv[ppsz_argc++] = "--no-fullscreen";
160 else if( !strcmp( argn[i], "mute" ) )
162 if( boolValue(argv[i]) )
164 ppsz_argv[ppsz_argc++] = "--volume=0";
167 else if( !strcmp( argn[i], "loop")
168 || !strcmp( argn[i], "autoloop") )
170 if( boolValue(argv[i]) )
172 ppsz_argv[ppsz_argc++] = "--loop";
176 ppsz_argv[ppsz_argc++] = "--no-loop";
179 else if( !strcmp( argn[i], "version")
180 || !strcmp( argn[i], "progid") )
184 else if( !strcmp( argn[i], "toolbar" ) )
186 /* FIXME: Remove this when toolbar functionality has been implemented on\
187 * MacOS X and Win32 for Firefox/Mozilla/Safari. */
189 b_toolbar = boolValue(argv[i]);
194 libvlc_exception_t ex;
195 libvlc_exception_init(&ex);
197 libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, &ex);
199 if( libvlc_exception_raised(&ex) )
201 libvlc_exception_clear(&ex);
202 return NPERR_GENERIC_ERROR;
205 libvlc_media_list = libvlc_media_list_new(libvlc_instance,&ex);
206 if( libvlc_exception_raised(&ex) )
208 libvlc_exception_clear(&ex);
209 return NPERR_GENERIC_ERROR;
213 ** fetch plugin base URL, which is the URL of the page containing the plugin
214 ** this URL is used for making absolute URL from relative URL that may be
215 ** passed as an MRL argument
219 if( NPERR_NO_ERROR == NPN_GetValue(p_browser, NPNVWindowNPObject, &plugin) )
222 ** is there a better way to get that info ?
224 static const char docLocHref[] = "document.location.href";
228 script.utf8characters = docLocHref;
229 script.utf8length = sizeof(docLocHref)-1;
231 if( NPN_Evaluate(p_browser, plugin, &script, &result) )
233 if( NPVARIANT_IS_STRING(result) )
235 NPString &location = NPVARIANT_TO_STRING(result);
237 psz_baseURL = static_cast<char*>(malloc(location.utf8length+1));
240 strncpy(psz_baseURL, location.utf8characters, location.utf8length);
241 psz_baseURL[location.utf8length] = '\0';
244 NPN_ReleaseVariantValue(&result);
246 NPN_ReleaseObject(plugin);
251 // get absolute URL from src
252 char *psz_absurl = getAbsoluteURL(psz_target);
253 psz_target = psz_absurl ? psz_absurl : strdup(psz_target);
256 /* assign plugin script root class */
258 p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();
260 return NPERR_NO_ERROR;
263 VlcPlugin::~VlcPlugin()
268 libvlc_log_close(libvlc_log, NULL);
269 if( libvlc_media_player )
270 libvlc_media_player_release( libvlc_media_player );
271 if( libvlc_media_list )
272 libvlc_media_list_release( libvlc_media_list );
273 if( libvlc_instance )
274 libvlc_release(libvlc_instance);
277 /*****************************************************************************
278 * VlcPlugin playlist replacement methods
279 *****************************************************************************/
280 void VlcPlugin::set_player_window( libvlc_exception_t *ex )
283 libvlc_media_player_set_xwindow(libvlc_media_player,
284 (libvlc_drawable_t)getVideoWindow(),
288 // XXX FIXME insert appropriate call here
291 libvlc_media_player_set_hwnd(libvlc_media_player,
297 int VlcPlugin::playlist_add( const char *mrl, libvlc_exception_t *ex )
300 libvlc_media_t *p_m = libvlc_media_new(libvlc_instance,mrl,ex);
301 if( libvlc_exception_raised(ex) )
304 libvlc_media_list_lock(libvlc_media_list);
305 libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
306 if( !libvlc_exception_raised(ex) )
307 item = libvlc_media_list_count(libvlc_media_list,ex)-1;
308 libvlc_media_list_unlock(libvlc_media_list);
310 libvlc_media_release(p_m);
315 int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *name,
316 int optc, const char **optv, libvlc_exception_t *ex )
318 libvlc_media_t *p_m = libvlc_media_new(libvlc_instance, mrl,ex);
320 if( libvlc_exception_raised(ex) )
323 for( int i = 0; i < optc; ++i )
325 libvlc_media_add_option_untrusted(p_m, optv[i],ex);
326 if( libvlc_exception_raised(ex) )
328 libvlc_media_release(p_m);
333 libvlc_media_list_lock(libvlc_media_list);
334 libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
335 if( !libvlc_exception_raised(ex) )
336 item = libvlc_media_list_count(libvlc_media_list,ex)-1;
337 libvlc_media_list_unlock(libvlc_media_list);
338 libvlc_media_release(p_m);
343 void VlcPlugin::playlist_play( libvlc_exception_t *ex )
345 if( libvlc_media_player||playlist_select(0,ex) )
346 libvlc_media_player_play(libvlc_media_player,ex);
349 void VlcPlugin::playlist_play_item( int idx, libvlc_exception_t *ex )
351 if( playlist_select(idx,ex) )
352 libvlc_media_player_play(libvlc_media_player,ex);
355 void VlcPlugin::playlist_stop( libvlc_exception_t *ex )
357 if( libvlc_media_player )
358 libvlc_media_player_stop(libvlc_media_player,ex);
361 bool VlcPlugin::playlist_select( int idx, libvlc_exception_t *ex )
363 libvlc_media_t *p_m = NULL;
365 libvlc_media_list_lock(libvlc_media_list);
367 int count = libvlc_media_list_count(libvlc_media_list,ex);
368 if( libvlc_exception_raised(ex) )
371 if( idx<0||idx>=count )
374 playlist_index = idx;
376 p_m = libvlc_media_list_item_at_index(libvlc_media_list,playlist_index,ex);
377 libvlc_media_list_unlock(libvlc_media_list);
379 if( libvlc_exception_raised(ex) )
382 if( libvlc_media_player )
384 libvlc_media_player_release( libvlc_media_player );
385 libvlc_media_player = NULL;
388 libvlc_media_player = libvlc_media_player_new_from_media(p_m,ex);
389 if( libvlc_media_player )
390 set_player_window(ex);
392 libvlc_media_release( p_m );
393 return !libvlc_exception_raised(ex);
396 libvlc_media_list_unlock(libvlc_media_list);
400 void VlcPlugin::playlist_next( libvlc_exception_t *ex )
402 if( playlist_select(playlist_index+1,ex) )
403 libvlc_media_player_play(libvlc_media_player,ex);
406 void VlcPlugin::playlist_prev( libvlc_exception_t *ex )
408 if( playlist_select(playlist_index-1,ex) )
409 libvlc_media_player_play(libvlc_media_player,ex);
412 void VlcPlugin::playlist_pause( libvlc_exception_t *ex )
414 if( libvlc_media_player )
415 libvlc_media_player_pause(libvlc_media_player,ex);
418 void VlcPlugin::playlist_delete_item( int idx, libvlc_exception_t *ex )
420 libvlc_media_list_lock(libvlc_media_list);
421 libvlc_media_list_remove_index(libvlc_media_list,idx,ex);
422 libvlc_media_list_unlock(libvlc_media_list);
425 void VlcPlugin::playlist_clear( libvlc_exception_t *ex )
427 if( libvlc_media_list )
428 libvlc_media_list_release(libvlc_media_list);
429 libvlc_media_list = libvlc_media_list_new(getVLC(),ex);
432 int VlcPlugin::playlist_count( libvlc_exception_t *ex )
435 libvlc_media_list_lock(libvlc_media_list);
436 items_count = libvlc_media_list_count(libvlc_media_list,ex);
437 libvlc_media_list_unlock(libvlc_media_list);
441 int VlcPlugin::playlist_isplaying( libvlc_exception_t *ex )
444 if( libvlc_media_player )
445 libvlc_media_player_is_playing( libvlc_media_player, ex );
449 void VlcPlugin::toggle_fullscreen( libvlc_exception_t *ex )
451 if( playlist_isplaying(ex) )
452 libvlc_toggle_fullscreen(libvlc_media_player,ex);
455 void VlcPlugin::set_fullscreen( int yes, libvlc_exception_t *ex )
457 if( playlist_isplaying(ex) )
458 libvlc_set_fullscreen(libvlc_media_player,yes,ex);
461 int VlcPlugin::get_fullscreen( libvlc_exception_t *ex )
464 if( playlist_isplaying(ex) )
465 r = libvlc_get_fullscreen(libvlc_media_player,ex);
469 int VlcPlugin::player_has_vout( libvlc_exception_t *ex )
472 if( playlist_isplaying(ex) )
473 r = libvlc_media_player_has_vout(libvlc_media_player, ex);
478 /*****************************************************************************
480 *****************************************************************************/
482 char *VlcPlugin::getAbsoluteURL(const char *url)
486 // check whether URL is already absolute
487 const char *end=strchr(url, ':');
488 if( (NULL != end) && (end != url) )
490 // validate protocol header
491 const char *start = url;
496 while( start != end )
503 || ('/' == c)) ) /* VLC uses / to allow user to specify a demuxer */
504 // not valid protocol header, assume relative URL
508 /* we have a protocol header, therefore URL is absolute */
511 // not a valid protocol header, assume relative URL
518 size_t baseLen = strlen(psz_baseURL);
519 char *href = static_cast<char*>(malloc(baseLen+strlen(url)+1));
522 /* prepend base URL */
523 strcpy(href, psz_baseURL);
526 ** relative url could be empty,
527 ** in which case return base URL
533 ** locate pathname part of base URL
536 /* skip over protocol part */
537 char *pathstart = strchr(href, ':');
541 if( '/' == *(++pathstart) )
543 if( '/' == *(++pathstart) )
548 /* skip over host part */
549 pathstart = strchr(pathstart, '/');
550 pathend = href+baseLen;
553 // no path, add a / past end of url (over '\0')
560 /* baseURL is just a UNIX path */
563 /* baseURL is not an absolute path */
568 pathend = href+baseLen;
571 /* relative URL made of an absolute path ? */
574 /* replace path completely */
575 strcpy(pathstart, url);
579 /* find last path component and replace it */
580 while( '/' != *pathend)
584 ** if relative url path starts with one or more '../',
585 ** factor them out of href so that we return a
588 while( pathend != pathstart )
596 /* relative url is just '.' */
602 /* relative url starts with './' */
611 /* relative url is '..' */
617 /* relative url starts with '../' */
625 while( '/' != *pathend );
627 /* skip over '/' separator */
629 /* concatenate remaining base URL and relative URL */
630 strcpy(pathend, url);
639 int VlcPlugin::setSize(unsigned width, unsigned height)
641 int diff = (width != i_width) || (height != i_height);
650 #define BTN_SPACE ((unsigned int)4)
651 void VlcPlugin::showToolbar()
653 const NPWindow& window = getWindow();
654 Window control = getControlWindow();
655 Window video = getVideoWindow();
656 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
657 unsigned int i_height = 0, i_width = BTN_SPACE;
661 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm",
662 &p_btnPlay, NULL, NULL);
665 i_height = __MAX( i_height, p_btnPlay->height );
668 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm",
669 &p_btnPause, NULL, NULL);
672 i_height = __MAX( i_height, p_btnPause->height );
674 i_width += __MAX( p_btnPause->width, p_btnPlay->width );
677 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm",
678 &p_btnStop, NULL, NULL );
681 i_height = __MAX( i_height, p_btnStop->height );
682 i_width += BTN_SPACE + p_btnStop->width;
685 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm",
686 &p_timeline, NULL, NULL);
689 i_height = __MAX( i_height, p_timeline->height );
690 i_width += BTN_SPACE + p_timeline->width;
693 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm",
694 &p_btnTime, NULL, NULL);
697 i_height = __MAX( i_height, p_btnTime->height );
698 i_width += BTN_SPACE + p_btnTime->width;
700 if( !p_btnFullscreen )
701 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm",
702 &p_btnFullscreen, NULL, NULL);
703 if( p_btnFullscreen )
705 i_height = __MAX( i_height, p_btnFullscreen->height );
706 i_width += BTN_SPACE + p_btnFullscreen->width;
709 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm",
710 &p_btnMute, NULL, NULL);
713 i_height = __MAX( i_height, p_btnMute->height );
716 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm",
717 &p_btnUnmute, NULL, NULL);
720 i_height = __MAX( i_height, p_btnUnmute->height );
722 i_width += BTN_SPACE + __MAX( p_btnUnmute->width, p_btnMute->width );
724 setToolbarSize( i_width, i_height );
726 if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline ||
727 !p_btnTime || !p_btnFullscreen || !p_btnMute || !p_btnUnmute )
728 fprintf(stderr, "Error: some button images not found in %s\n", DATA_PATH );
730 /* reset panels position and size */
731 /* XXX use i_width */
732 XResizeWindow( p_display, video, window.width, window.height - i_height);
733 XMoveWindow( p_display, control, 0, window.height - i_height );
734 XResizeWindow( p_display, control, window.width, i_height -1);
736 b_toolbar = 1; /* says toolbar is now shown */
740 void VlcPlugin::hideToolbar()
742 const NPWindow& window = getWindow();
743 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
744 Window control = getControlWindow();
745 Window video = getVideoWindow();
747 i_tb_width = i_tb_height = 0;
749 if( p_btnPlay ) XDestroyImage( p_btnPlay );
750 if( p_btnPause ) XDestroyImage( p_btnPause );
751 if( p_btnStop ) XDestroyImage( p_btnStop );
752 if( p_timeline ) XDestroyImage( p_timeline );
753 if( p_btnTime ) XDestroyImage( p_btnTime );
754 if( p_btnFullscreen ) XDestroyImage( p_btnFullscreen );
755 if( p_btnMute ) XDestroyImage( p_btnMute );
756 if( p_btnUnmute ) XDestroyImage( p_btnUnmute );
763 p_btnFullscreen = NULL;
767 /* reset panels position and size */
768 /* XXX use i_width */
769 XResizeWindow( p_display, video, window.width, window.height );
770 XMoveWindow( p_display, control, 0, window.height-1 );
771 XResizeWindow( p_display, control, window.width, 1 );
773 b_toolbar = 0; /* says toolbar is now hidden */
777 void VlcPlugin::redrawToolbar()
779 libvlc_exception_t ex;
782 unsigned int dst_x, dst_y;
785 unsigned int i_tb_width, i_tb_height;
787 /* This method does nothing if toolbar is hidden. */
791 const NPWindow& window = getWindow();
792 Window control = getControlWindow();
793 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
795 getToolbarSize( &i_tb_width, &i_tb_height );
797 libvlc_exception_init( &ex );
800 b_mute = libvlc_audio_get_mute( getVLC(), &ex );
801 libvlc_exception_clear( &ex );
803 gcv.foreground = BlackPixel( p_display, 0 );
804 gc = XCreateGC( p_display, control, GCForeground, &gcv );
806 XFillRectangle( p_display, control, gc,
807 0, 0, window.width, i_tb_height );
808 gcv.foreground = WhitePixel( p_display, 0 );
809 XChangeGC( p_display, gc, GCForeground, &gcv );
813 dst_y = i_tb_height >> 1; /* baseline = vertical middle */
815 if( p_btnPause && (is_playing == 1) )
817 XPutImage( p_display, control, gc, p_btnPause, 0, 0, dst_x,
818 dst_y - (p_btnPause->height >> 1),
819 p_btnPause->width, p_btnPause->height );
820 dst_x += BTN_SPACE + p_btnPause->width;
824 XPutImage( p_display, control, gc, p_btnPlay, 0, 0, dst_x,
825 dst_y - (p_btnPlay->height >> 1),
826 p_btnPlay->width, p_btnPlay->height );
827 dst_x += BTN_SPACE + p_btnPlay->width;
831 XPutImage( p_display, control, gc, p_btnStop, 0, 0, dst_x,
832 dst_y - (p_btnStop->height >> 1),
833 p_btnStop->width, p_btnStop->height );
835 dst_x += BTN_SPACE + ( p_btnStop ? p_btnStop->width : 0 );
837 if( p_btnFullscreen )
838 XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, dst_x,
839 dst_y - (p_btnFullscreen->height >> 1),
840 p_btnFullscreen->width, p_btnFullscreen->height );
842 dst_x += BTN_SPACE + ( p_btnFullscreen ? p_btnFullscreen->width : 0 );
844 if( p_btnUnmute && b_mute )
846 XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, dst_x,
847 dst_y - (p_btnUnmute->height >> 1),
848 p_btnUnmute->width, p_btnUnmute->height );
850 dst_x += BTN_SPACE + ( p_btnUnmute ? p_btnUnmute->width : 0 );
854 XPutImage( p_display, control, gc, p_btnMute, 0, 0, dst_x,
855 dst_y - (p_btnMute->height >> 1),
856 p_btnMute->width, p_btnMute->height );
858 dst_x += BTN_SPACE + ( p_btnMute ? p_btnMute->width : 0 );
862 XPutImage( p_display, control, gc, p_timeline, 0, 0, dst_x,
863 dst_y - (p_timeline->height >> 1),
864 (window.width-(dst_x+BTN_SPACE)), p_timeline->height );
868 /* get movie position in % */
869 if( playlist_isplaying(&ex) )
871 i_last_position = (int)((window.width-(dst_x+BTN_SPACE))*
872 libvlc_media_player_get_position(libvlc_media_player,&ex));
874 libvlc_exception_clear( &ex );
877 XPutImage( p_display, control, gc, p_btnTime,
878 0, 0, (dst_x+i_last_position),
879 dst_y - (p_btnTime->height >> 1),
880 p_btnTime->width, p_btnTime->height );
882 XFreeGC( p_display, gc );
885 vlc_toolbar_clicked_t VlcPlugin::getToolbarButtonClicked( int i_xpos, int i_ypos )
887 unsigned int i_dest = BTN_SPACE;//(i_tb_height >> 1);
890 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;