Commit ea848bc4 authored by Sergey Radionov's avatar Sergey Radionov Committed by Jean-Baptiste Kempf

npapi: switch to vlc_player_options

Modified-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 75229ae8
......@@ -350,12 +350,7 @@ void EventObj::unhook_manager( void *userdata )
VlcPluginBase::VlcPluginBase( NPP instance, NPuint16_t mode ) :
i_npmode(mode),
b_stream(0),
b_autoplay(1),
b_toolbar(1),
b_allowfullscreen(1),
psz_text(NULL),
psz_target(NULL),
psz_bgcolor("#000000"),
playlist_index(-1),
libvlc_instance(NULL),
libvlc_media_list(NULL),
......@@ -457,18 +452,17 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
}
else if( !strcmp( argn[i], "text" ) )
{
free( psz_text );
psz_text = strdup( argv[i] );
set_bg_text( argv[i] );
}
else if( !strcmp( argn[i], "autoplay")
|| !strcmp( argn[i], "autostart") )
{
b_autoplay = boolValue(argv[i]);
set_autoplay(boolValue(argv[i]));
}
else if( !strcmp( argn[i], "fullscreen" )
|| !strcmp( argn[i], "allowfullscreen" ) )
{
b_allowfullscreen = boolValue(argv[i]);
set_enable_fs( boolValue(argv[i]) );
}
else if( !strcmp( argn[i], "mute" ) )
{
......@@ -491,11 +485,11 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
}
else if( !strcmp( argn[i], "toolbar" ) )
{
b_toolbar = boolValue(argv[i]);
set_show_toolbar( boolValue(argv[i]) );
}
else if( !strcmp( argn[i], "bgcolor" ) )
{
psz_bgcolor = strdup( argv[i] );
set_bg_color( argv[i] );
}
}
......@@ -562,7 +556,6 @@ VlcPluginBase::~VlcPluginBase()
{
free(psz_baseURL);
free(psz_target);
free(psz_text);
if( libvlc_media_player )
{
......
......@@ -81,6 +81,7 @@
#include <assert.h>
#include "control/nporuntime.h"
#include "../common/vlc_player_options.h"
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
typedef uint16 NPuint16_t;
......@@ -189,7 +190,7 @@ typedef enum vlc_toolbar_clicked_e {
clicked_Unmute
} vlc_toolbar_clicked_t;
class VlcPluginBase
class VlcPluginBase: public vlc_player_options
{
protected:
......@@ -222,10 +223,6 @@ public:
/* plugin properties */
int b_stream;
int b_autoplay;
int b_toolbar;
int b_allowfullscreen;
char * psz_text;
char * psz_target;
void playlist_play()
......@@ -321,7 +318,6 @@ protected:
/* display settings */
NPWindow npwindow;
const char *psz_bgcolor;
static void eventAsync(void *);
......
......@@ -104,7 +104,7 @@ void VlcPluginGtk::do_set_fullscreen(bool yes)
void VlcPluginGtk::set_fullscreen(int yes)
{
if (!b_allowfullscreen) return;
if (!get_enable_fs()) return;
if (yes == is_fullscreen) return;
if (yes) {
gtk_widget_show(fullscreen_win);
......@@ -213,7 +213,7 @@ void VlcPluginGtk::popup_menu()
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_handler), this);
gtk_menu_shell_append(GTK_MENU_SHELL(popupmenu), menuitem);
/* set fullscreen */
if (b_allowfullscreen) {
if (get_enable_fs()) {
menuitem = gtk_image_menu_item_new_from_stock(
GTK_STOCK_FULLSCREEN, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_handler), this);
......@@ -357,7 +357,7 @@ bool VlcPluginGtk::create_windows()
Window socket = (Window) npwindow.window;
GdkColor color_bg;
gdk_color_parse(psz_bgcolor, &color_bg);
gdk_color_parse(get_bg_color().c_str(), &color_bg);
parent = gtk_plug_new(socket);
gtk_widget_modify_bg(parent, GTK_STATE_NORMAL, &color_bg);
......
......@@ -42,14 +42,14 @@ void VlcPluginMac::set_player_window()
void VlcPluginMac::toggle_fullscreen()
{
if (!b_allowfullscreen) return;
if (!get_enable_fs()) return;
if (playlist_isplaying())
libvlc_toggle_fullscreen(libvlc_media_player);
}
void VlcPluginMac::set_fullscreen(int yes)
{
if (!b_allowfullscreen) return;
if (!get_enable_fs()) return;
if (playlist_isplaying())
libvlc_set_fullscreen(libvlc_media_player, yes);
}
......
......@@ -87,7 +87,7 @@ LRESULT CALLBACK VlcPluginWin::NPWndProcR(HWND hWnd, UINT uMsg, WPARAM wParam, L
VlcPluginWin::VlcPluginWin(NPP instance, NPuint16_t mode) :
VlcPluginBase(instance, mode), _NPWndProc(0),
_WindowsManager(DllGetModule(), _ViewRC)
_WindowsManager(DllGetModule(), _ViewRC, this)
{
_ViewRC.hDeFullscreenBitmap =
LoadImage(DllGetModule(), MAKEINTRESOURCE(3),
......@@ -125,13 +125,11 @@ VlcPluginWin::~VlcPluginWin()
void VlcPluginWin::toggle_fullscreen()
{
if (!b_allowfullscreen) return;
_WindowsManager.ToggleFullScreen();
}
void VlcPluginWin::set_fullscreen(int yes)
{
if (!b_allowfullscreen) return;
if(yes){
_WindowsManager.StartFullScreen();
}
......
......@@ -48,14 +48,14 @@ void VlcPluginXcb::set_player_window()
void VlcPluginXcb::toggle_fullscreen()
{
if (!b_allowfullscreen) return;
if (!get_enable_fs()) return;
if (playlist_isplaying())
libvlc_toggle_fullscreen(libvlc_media_player);
}
void VlcPluginXcb::set_fullscreen(int yes)
{
if (!b_allowfullscreen) return;
if (!get_enable_fs()) return;
if (playlist_isplaying())
libvlc_set_fullscreen(libvlc_media_player,yes);
}
......@@ -83,7 +83,7 @@ bool VlcPluginXcb::create_windows()
xcb_atom_t xembed_info_atom = xcb_intern_atom_reply(conn, cookie, NULL)->atom;
/* create windows */
/* TODO: respect psz_bgcolor */
/* TODO: respect get_bg_color() */
const uint32_t parent_values[] = {0x0FFFFF};
parent = xcb_generate_id(conn);
xcb_create_window(conn, XCB_COPY_FROM_PARENT, parent, socket,
......
......@@ -188,7 +188,7 @@ int16_t NPP_HandleEvent( NPP instance, void * event )
if( ! hasVout )
{
/* draw the text from p_plugin->psz_text */
/* draw the text from get_bg_text() */
ForeColor(blackColor);
PenMode( patCopy );
......@@ -206,8 +206,8 @@ int16_t NPP_HandleEvent( NPP instance, void * event )
ForeColor(whiteColor);
MoveTo( (npwindow.width-80)/ 2 , npwindow.height / 2 );
if( p_plugin->psz_text )
DrawText( p_plugin->psz_text, 0, strlen(p_plugin->psz_text) );
if( !p_plugin->get_bg_text().empty() )
DrawText( p_plugin->get_bg_text().c_str(), 0, p_plugin->get_bg_text().length() );
}
}
return true;
......@@ -350,7 +350,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
p_plugin->resize_windows();
/* now set plugin state to that requested in parameters */
p_plugin->set_toolbar_visible( p_plugin->b_toolbar );
p_plugin->set_toolbar_visible( p_plugin->get_show_toolbar() );
/* handle streams properly */
if( !p_plugin->b_stream )
......@@ -359,7 +359,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
if( p_plugin->playlist_add( p_plugin->psz_target ) != -1 )
{
if( p_plugin->b_autoplay )
if( p_plugin->get_autoplay() )
{
p_plugin->playlist_play();
}
......@@ -459,7 +459,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
if( p_plugin->playlist_add( stream->url ) != -1 )
{
if( p_plugin->b_autoplay )
if( p_plugin->get_autoplay() )
{
p_plugin->playlist_play();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment