Commit 08e1f2d5 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Plugin classes do not inherit from vlc_player anymore

parent abd4e591
......@@ -965,7 +965,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_play:
if( argCount == 0 )
{
p_plugin->playlist_play();
p_plugin->player().play();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
......
......@@ -179,13 +179,13 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
try {
VLC::Instance instance( ppsz_argc, ppsz_argv );
vlc_player::open(instance);
m_player.open(instance);
}
catch (std::runtime_error&) {
return NPERR_GENERIC_ERROR;
}
vlc_player::set_mode(b_autoloop ? libvlc_playback_mode_loop :
m_player.set_mode(b_autoloop ? libvlc_playback_mode_loop :
libvlc_playback_mode_default);
/*
......@@ -365,55 +365,55 @@ void VlcPluginBase::subscribe(const char* eventName, npapi::Variant listener)
switch ( event->type )
{
case libvlc_MediaPlayerNothingSpecial:
e = get_mp().eventManager().onNothingSpecial( std::move( closure ) );
e = player().get_mp().eventManager().onNothingSpecial( std::move( closure ) );
break;
case libvlc_MediaPlayerOpening:
e = get_mp().eventManager().onOpening( std::move( closure ) );
e = player().get_mp().eventManager().onOpening( std::move( closure ) );
break;
case libvlc_MediaPlayerPlaying:
e = get_mp().eventManager().onPlaying( std::move( closure ) );
e = player().get_mp().eventManager().onPlaying( std::move( closure ) );
break;
case libvlc_MediaPlayerPaused:
e = get_mp().eventManager().onPaused( std::move( closure ) );
e = player().get_mp().eventManager().onPaused( std::move( closure ) );
break;
case libvlc_MediaPlayerStopped:
e = get_mp().eventManager().onStopped( std::move( closure ) );
e = player().get_mp().eventManager().onStopped( std::move( closure ) );
break;
case libvlc_MediaPlayerForward:
e = get_mp().eventManager().onForward( std::move( closure ) );
e = player().get_mp().eventManager().onForward( std::move( closure ) );
break;
case libvlc_MediaPlayerBackward:
e = get_mp().eventManager().onBackward( std::move( closure ) );
e = player().get_mp().eventManager().onBackward( std::move( closure ) );
break;
case libvlc_MediaPlayerEndReached:
e = get_mp().eventManager().onEndReached( std::move( closure ) );
e = player().get_mp().eventManager().onEndReached( std::move( closure ) );
break;
case libvlc_MediaPlayerEncounteredError:
e = get_mp().eventManager().onEncounteredError( std::move( closure ) );
e = player().get_mp().eventManager().onEncounteredError( std::move( closure ) );
break;
case libvlc_MediaPlayerBuffering:
e = get_mp().eventManager().onBuffering( std::move( closure ) );
e = player().get_mp().eventManager().onBuffering( std::move( closure ) );
break;
case libvlc_MediaPlayerTimeChanged:
e = get_mp().eventManager().onTimeChanged( std::move( closure ) );
e = player().get_mp().eventManager().onTimeChanged( std::move( closure ) );
break;
case libvlc_MediaPlayerMediaChanged:
e = get_mp().eventManager().onMediaChanged( std::move( closure ) );
e = player().get_mp().eventManager().onMediaChanged( std::move( closure ) );
break;
case libvlc_MediaPlayerPositionChanged:
e = get_mp().eventManager().onPositionChanged( std::move( closure ) );
e = player().get_mp().eventManager().onPositionChanged( std::move( closure ) );
break;
case libvlc_MediaPlayerSeekableChanged:
e = get_mp().eventManager().onSeekableChanged( std::move( closure ) );
e = player().get_mp().eventManager().onSeekableChanged( std::move( closure ) );
break;
case libvlc_MediaPlayerPausableChanged:
e = get_mp().eventManager().onPausableChanged( std::move( closure ) );
e = player().get_mp().eventManager().onPausableChanged( std::move( closure ) );
break;
case libvlc_MediaPlayerTitleChanged:
e = get_mp().eventManager().onTitleChanged( std::move( closure ) );
e = player().get_mp().eventManager().onTitleChanged( std::move( closure ) );
break;
case libvlc_MediaPlayerLengthChanged:
e = get_mp().eventManager().onLengthChanged( std::move( closure ) );
e = player().get_mp().eventManager().onLengthChanged( std::move( closure ) );
break;
default:
break;
......@@ -440,10 +440,9 @@ void VlcPluginBase::unsubscribe(const char* eventName, npapi::Variant listener)
*****************************************************************************/
bool VlcPluginBase::player_has_vout()
{
bool r = false;
if( playlist_isplaying() )
r = libvlc_media_player_has_vout(get_mp())!=0;
return r;
return player().get_mp().hasVout() != 0;
return false;
}
/*****************************************************************************
......@@ -610,7 +609,7 @@ void VlcPluginBase::control_handler(vlc_toolbar_clicked_t clicked)
{
case clicked_Play:
{
playlist_play();
player().play();
}
break;
......
......@@ -56,7 +56,7 @@ typedef enum vlc_toolbar_clicked_e {
clicked_Unmute
} vlc_toolbar_clicked_t;
class VlcPluginBase: private vlc_player_options, private vlc_player
class VlcPluginBase: private vlc_player_options
{
protected:
......@@ -64,11 +64,6 @@ public:
VlcPluginBase( NPP, NPuint16_t );
virtual ~VlcPluginBase();
vlc_player& get_player()
{
return *static_cast<vlc_player*>(this);
}
vlc_player_options& get_options()
{ return *static_cast<vlc_player_options*>(this); }
const vlc_player_options& get_options() const
......@@ -78,7 +73,7 @@ public:
VLC::MediaPlayer& getMD()
{
return get_mp();
return m_player.get_mp();
}
NPP getBrowser() { return p_browser; };
......@@ -95,62 +90,58 @@ public:
int b_stream;
char * psz_target;
void playlist_play()
{
play();
}
void playlist_play_item(int idx)
{
play(idx);
m_player.play(idx);
}
void playlist_stop()
{
stop();
m_player.stop();
}
void playlist_next()
{
next();
m_player.next();
}
void playlist_prev()
{
prev();
m_player.prev();
}
void playlist_pause()
{
pause();
m_player.pause();
}
void playlist_togglePause()
{
togglePause();
m_player.togglePause();
}
int playlist_isplaying()
{
return is_playing();
return m_player.is_playing();
}
int playlist_currentitem()
{
return current_item();
return m_player.current_item();
}
int playlist_add( const char * mrl)
{
return add_item(mrl);
return m_player.add_item(mrl);
}
int playlist_add_extended_untrusted( const char *mrl, const char *,
int optc, const char **optv )
{
return add_item(mrl, optc, optv);
return m_player.add_item(mrl, optc, optv);
}
int playlist_delete_item( int idx)
{
return delete_item(idx);
return m_player.delete_item(idx);
}
void playlist_clear()
{
clear_items() ;
m_player.clear_items() ;
}
int playlist_count()
{
return items_count();
return m_player.items_count();
}
bool playlist_select(int);
......@@ -158,6 +149,11 @@ public:
bool player_has_vout();
vlc_player& player()
{
return m_player;
}
virtual bool create_windows() = 0;
virtual bool resize_windows() = 0;
virtual bool destroy_windows() = 0;
......@@ -199,6 +195,8 @@ protected:
/* display settings */
NPWindow npwindow;
vlc_player m_player;
private:
static std::set<VlcPluginBase*> _instances;
......
......@@ -61,8 +61,8 @@ VlcPluginGtk::~VlcPluginGtk()
void VlcPluginGtk::set_player_window()
{
get_player().get_mp().setXwindow( video_xwindow);
get_player().get_mp().setMouseInput( false );
player().get_mp().setXwindow( video_xwindow);
player().get_mp().setMouseInput( false );
}
void VlcPluginGtk::toggle_fullscreen()
......@@ -376,7 +376,7 @@ static gboolean fullscreen_win_keypress_handler(GtkWidget *widget, GdkEventKey *
void VlcPluginGtk::update_controls()
{
libvlc_state_t state = get_player().get_mp().state();
auto state = player().get_mp().state();
if ( state == libvlc_Stopped || state == libvlc_Ended || state == libvlc_Error ) {
XUnmapWindow(display, video_xwindow);
} else {
......@@ -402,12 +402,12 @@ void VlcPluginGtk::update_controls()
gtk_widget_set_sensitive( toolbar, true );
/* time slider */
if (!get_player().get_mp().isSeekable()) {
if (!player().get_mp().isSeekable()) {
gtk_widget_set_sensitive(time_slider, false);
gtk_range_set_value(GTK_RANGE(time_slider), 0);
} else {
gtk_widget_set_sensitive(time_slider, true);
gdouble timepos = 100.0 * get_player().get_mp().position();
gdouble timepos = 100.0 * player().get_mp().position();
if (time_slider_timeout_id == 0) {
/* only set the time if the user is not dragging the slider */
gtk_range_set_value(GTK_RANGE(time_slider), timepos);
......
......@@ -369,7 +369,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
if( p_plugin->get_options().get_autoplay() )
{
p_plugin->playlist_play();
p_plugin->player().play();
}
}
p_plugin->b_stream = true;
......@@ -470,7 +470,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* )
{
if( p_plugin->get_options().get_autoplay() )
{
p_plugin->playlist_play();
p_plugin->player().play();
}
}
}
......
vlcpp @ 7602f030
Subproject commit 6297c12addf623e85f471748088d079603e33afc
Subproject commit 7602f030e07209a135310652fd00413a082f86ef
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