/*****************************************************************************
* vlcplugin.cpp: a VLC plugin for Mozilla
*****************************************************************************
- * Copyright (C) 2002-2008 the VideoLAN team
+ * Copyright (C) 2002-2009 the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
{
/* prepare VLC command line */
- char *ppsz_argv[32];
+ const char *ppsz_argv[32];
int ppsz_argc = 0;
/* locate VLC module path */
#ifdef XP_MACOSX
- ppsz_argv[ppsz_argc++] = "--plugin-path";
- ppsz_argv[ppsz_argc++] = "/Library/Internet Plug-Ins/VLC Plugin.plugin/"
- "Contents/MacOS/modules";
+ ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules";
+ ppsz_argv[ppsz_argc++] = "--vout=macosx";
#elif defined(XP_WIN)
HKEY h_key;
DWORD i_type, i_data = MAX_PATH + 1;
ppsz_argv[ppsz_argc++] = "--no-stats";
ppsz_argv[ppsz_argc++] = "--no-media-library";
ppsz_argv[ppsz_argc++] = "--ignore-config";
- ppsz_argv[ppsz_argc++] = "--intf";
- ppsz_argv[ppsz_argc++] = "dummy";
-
+ ppsz_argv[ppsz_argc++] = "--intf=dummy";
const char *progid = NULL;
/* parse plugin arguments */
}
else if( !strcmp( argn[i], "toolbar" ) )
{
+/* FIXME: Remove this when toolbar functionality has been implemented on\
+ * MacOS X and Win32 for Firefox/Mozilla/Safari. */
+#ifdef XP_UNIX
b_toolbar = boolValue(argv[i]);
+#endif
}
}
{
NPString &location = NPVARIANT_TO_STRING(result);
- psz_baseURL = new char[location.utf8length+1];
+ psz_baseURL = static_cast<char*>(malloc(location.utf8length+1));
if( psz_baseURL )
{
strncpy(psz_baseURL, location.utf8characters, location.utf8length);
VlcPlugin::~VlcPlugin()
{
- delete[] psz_baseURL;
- delete psz_target;
+ free(psz_baseURL);
+ free(psz_target);
if( libvlc_log )
libvlc_log_close(libvlc_log, NULL);
if( libvlc_instance )
if( psz_baseURL )
{
size_t baseLen = strlen(psz_baseURL);
- char *href = new char[baseLen+strlen(url)+1];
+ char *href = static_cast<char*>(malloc(baseLen+strlen(url)+1));
if( href )
{
/* prepend base URL */
if( '/' != *href )
{
/* baseURL is not an absolute path */
- delete[] href;
+ free(href);
return NULL;
}
pathstart = href;
libvlc_media_player_t *p_md = NULL;
libvlc_exception_t ex;
float f_position = 0.0;
- int i_playing = 0;
+ int is_playing = 0;
bool b_mute = false;
unsigned int dst_x, dst_y;
GC gc;
libvlc_exception_init( &ex );
p_md = libvlc_playlist_get_media_player( getVLC(), &ex );
libvlc_exception_clear( &ex );
+ if( p_md )
+ {
+ /* get isplaying */
+ is_playing = libvlc_playlist_isplaying( getVLC(), &ex );
+ libvlc_exception_clear( &ex );
- /* get isplaying */
- i_playing = libvlc_playlist_isplaying( getVLC(), &ex );
- libvlc_exception_clear( &ex );
+ /* get movie position in % */
+ if( is_playing == 1 )
+ {
+ f_position = libvlc_media_player_get_position( p_md, &ex ) * 100.0;
+ libvlc_exception_clear( &ex );
+ }
+ libvlc_media_player_release( p_md );
+ }
/* get mute info */
b_mute = libvlc_audio_get_mute( getVLC(), &ex );
libvlc_exception_clear( &ex );
- /* get movie position in % */
- if( i_playing == 1 )
- {
- f_position = libvlc_media_player_get_position( p_md, &ex ) * 100;
- libvlc_exception_clear( &ex );
- }
- libvlc_media_player_release( p_md );
-
gcv.foreground = BlackPixel( p_display, 0 );
gc = XCreateGC( p_display, control, GCForeground, &gcv );
dst_x = BTN_SPACE;
dst_y = i_tb_height >> 1; /* baseline = vertical middle */
- if( p_btnPause && (i_playing == 1) )
+ if( p_btnPause && (is_playing == 1) )
{
XPutImage( p_display, control, gc, p_btnPause, 0, 0, dst_x,
dst_y - (p_btnPause->height >> 1),
vlc_toolbar_clicked_t VlcPlugin::getToolbarButtonClicked( int i_xpos, int i_ypos )
{
unsigned int i_dest = BTN_SPACE;//(i_tb_height >> 1);
- int i_playing = 0;
+ int is_playing = 0;
bool b_mute = false;
libvlc_exception_t ex;
/* get isplaying */
libvlc_exception_init( &ex );
- i_playing = libvlc_playlist_isplaying( getVLC(), &ex );
+ is_playing = libvlc_playlist_isplaying( getVLC(), &ex );
libvlc_exception_clear( &ex );
/* get mute info */
libvlc_exception_clear( &ex );
/* is Pause of Play button clicked */
- if( (i_playing != 1) &&
+ if( (is_playing != 1) &&
(i_xpos >= (BTN_SPACE>>1)) &&
(i_xpos <= i_dest + p_btnPlay->width + (BTN_SPACE>>1)) )
return clicked_Play;
return clicked_Pause;
/* is Stop button clicked */
- if( i_playing != 1 )
+ if( is_playing != 1 )
i_dest += (p_btnPlay->width + (BTN_SPACE>>1));
else
i_dest += (p_btnPause->width + (BTN_SPACE>>1));