X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=projects%2Fmozilla%2Fvlcshell.cpp;h=7adfca67c9d83655107076cb16175d503105736d;hb=4dd472bb412a29deef6d5a5424aaa081d27a5faf;hp=a3e783f9cb14c144975c3cc4c4ccbd60c2714120;hpb=227de1f76923c66c00711b6adb6721a5a325e28d;p=vlc diff --git a/projects/mozilla/vlcshell.cpp b/projects/mozilla/vlcshell.cpp index a3e783f9cb..7adfca67c9 100644 --- a/projects/mozilla/vlcshell.cpp +++ b/projects/mozilla/vlcshell.cpp @@ -1,10 +1,11 @@ /***************************************************************************** * vlcshell.cpp: a VLC plugin for Mozilla ***************************************************************************** - * Copyright (C) 2002-2005 the VideoLAN team + * Copyright (C) 2002-2008 the VideoLAN team * $Id$ * * Authors: Samuel Hocevar + * Jean-Paul Saman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -181,7 +182,6 @@ int16 NPP_HandleEvent( NPP instance, void * event ) { /* double click */ libvlc_instance_t *p_vlc = p_plugin->getVLC(); - if( p_vlc ) { if( libvlc_playlist_isplaying(p_vlc, NULL) ) @@ -364,7 +364,7 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save ) NPError NPP_SetWindow( NPP instance, NPWindow* window ) { -#ifdef XP_UNIX && !defined(__APPLE__) +#if defined(XP_UNIX) && !defined(__APPLE__) Window control; unsigned int i_control_height = 0, i_control_width = 0; #endif @@ -381,7 +381,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) /* we should probably show a splash screen here */ return NPERR_NO_ERROR; } -#ifdef XP_UNIX && !defined(__APPLE__) +#if defined(XP_UNIX) && !defined(__APPLE__) control = p_plugin->getControlWindow(); #endif libvlc_instance_t *p_vlc = p_plugin->getVLC(); @@ -836,38 +836,66 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) if( p_plugin && p_plugin->b_toolbar ) { + int i_playing; libvlc_exception_t ex; + libvlc_exception_init( &ex ); libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex); + if( libvlc_exception_raised(&ex) ) + fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); + libvlc_exception_clear( &ex ); + + i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex ); + if( libvlc_exception_raised(&ex) ) + fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); vlc_toolbar_clicked_t clicked; clicked = p_plugin->getToolbarButtonClicked( i_xPos, i_yPos ); - switch( clicked ) { case clicked_Play: case clicked_Pause: { - 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 ); + + if( libvlc_exception_raised(&ex) ) + fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); } break; case clicked_Stop: { - libvlc_exception_init( &ex ); libvlc_playlist_stop( p_plugin->getVLC(), &ex ); + if( libvlc_exception_raised(&ex) ) + fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); + libvlc_exception_clear( &ex ); + } + break; + + case clicked_Fullscreen: + { + if( (i_playing == 1) && p_md ) + { + libvlc_set_fullscreen( p_md, 1, &ex ); + if( libvlc_exception_raised(&ex) ) + fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); + libvlc_exception_clear( &ex ); + } + } + break; + + case clicked_Mute: + case clicked_Unmute: + { + libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex ); + if( libvlc_exception_raised(&ex) ) + fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); } break; @@ -878,15 +906,15 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) if( p_md ) { int64_t f_length; - libvlc_exception_init( &ex ); f_length = libvlc_media_player_get_length( p_md, &ex ) / 100; libvlc_exception_clear( &ex ); f_length = (float)f_length * ( ((float)i_xPos-4.0 ) / ( ((float)i_width-8.0)/100) ); - libvlc_exception_init( &ex ); libvlc_media_player_set_time( p_md, f_length, &ex ); + if( libvlc_exception_raised(&ex) ) + fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); } } @@ -898,31 +926,6 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) } break; - case clicked_Fullscreen: - { - int i_playing; - libvlc_exception_init( &ex ); - i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex ); - libvlc_exception_clear( &ex ); - - if( (i_playing == 1) && p_md ) - { - libvlc_exception_init( &ex ); - libvlc_set_fullscreen( p_md, 1, &ex ); - libvlc_exception_clear( &ex ); - } - } - break; - - case clicked_Mute: - case clicked_Unmute: - { - libvlc_exception_init( &ex ); - libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex ); - libvlc_exception_clear( &ex ); - } - break; - default: /* button_Unknown */ break; }