Commit 3388694d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Rework MediaListPlayer

Remove exceptions & usages of get_c_object
parent 45e30edc
......@@ -4,6 +4,7 @@
* Copyright © 2014 the VideoLAN team
*
* Authors: Alexey Sokolov <alexey@alexeysokolov.co.cc>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
......@@ -56,14 +57,12 @@ MediaListPlayer::~MediaListPlayer()
release();
}
MediaListPlayer::MediaListPlayer(Instance & p_instance)
MediaListPlayer* MediaListPlayer::create(Instance& instance)
{
m_obj = libvlc_media_list_player_new(p_instance.get_c_object());
if (!m_obj)
{
throw Exception("Can't construct MediaListPlayer");
}
InternalPtr ptr = libvlc_media_list_player_new( instance );
if ( ptr == NULL )
return NULL;
return new MediaListPlayer( ptr );
}
libvlc_event_manager_t * MediaListPlayer::eventManager()
......@@ -73,14 +72,14 @@ libvlc_event_manager_t * MediaListPlayer::eventManager()
return result;
}
void MediaListPlayer::setMediaPlayer(MediaPlayer & p_mi)
void MediaListPlayer::setMediaPlayer( MediaPlayer &mi )
{
libvlc_media_list_player_set_media_player(m_obj, p_mi.get_c_object());
libvlc_media_list_player_set_media_player( m_obj, mi );
}
void MediaListPlayer::setMediaList(MediaList & p_mlist)
void MediaListPlayer::setMediaList( MediaList &mlist )
{
libvlc_media_list_player_set_media_list(m_obj, p_mlist.get_c_object());
libvlc_media_list_player_set_media_list( m_obj, mlist );
}
void MediaListPlayer::play()
......@@ -114,9 +113,9 @@ int MediaListPlayer::playItemAtIndex(int i_index)
return result;
}
int MediaListPlayer::playItem(Media & p_md)
int MediaListPlayer::playItem(Media & p_md)
{
int c_result = libvlc_media_list_player_play_item(m_obj, p_md.get_c_object());
int c_result = libvlc_media_list_player_play_item( m_obj, p_md );
int result = c_result;
return result;
}
......@@ -145,6 +144,11 @@ void MediaListPlayer::setPlaybackMode(libvlc_playback_mode_t e_mode)
libvlc_media_list_player_set_playback_mode(m_obj, e_mode);
}
MediaListPlayer::MediaListPlayer(Internal::InternalPtr ptr)
: Internal( ptr )
{
}
void MediaListPlayer::release()
{
libvlc_media_list_player_release(m_obj);
......
......@@ -4,6 +4,7 @@
* Copyright © 2014 the VideoLAN team
*
* Authors: Alexey Sokolov <alexey@alexeysokolov.co.cc>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
......@@ -65,7 +66,7 @@ public:
*
* \param p_instance libvlc instance
*/
MediaListPlayer(Instance & p_instance);
static MediaListPlayer* create(Instance & instance);
/**
* Return the event manager of this media_list_player.
......@@ -86,7 +87,7 @@ public:
*
* \param p_mlist list of media
*/
void setMediaList(MediaList & p_mlist);
void setMediaList(MediaList & mlist);
/**
* Play media list
......@@ -157,6 +158,7 @@ public:
void setPlaybackMode(libvlc_playback_mode_t e_mode);
private:
MediaListPlayer(InternalPtr ptr);
/**
* Release a media_list_player after use Decrement the reference count of
* a media player object. If the reference count is 0, then
......
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