Commit bad4c91b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Added a tiny binding for Media List.

Not quite functionnal yet, but big refactoring comes first :)
parent b020885f
#include <QtDebug>
#include "VLCMediaList.h"
#include "VLCInstance.h"
using namespace LibVLCpp;
MediaList::MediaList() : m_listPlayer( NULL )
{
//Initializing media list :
m_internalPtr = libvlc_media_list_new( *(Instance::getInstance()), m_exception );
m_exception.checkThrow();
//Initializing list_player :
m_listPlayer = libvlc_media_list_player_new( *(Instance::getInstance()), m_exception );
m_exception.checkThrow();
//Associating player with media list :
libvlc_media_list_player_set_media_list( m_listPlayer, m_internalPtr, m_exception );
m_exception.checkThrow();
//Initializing event manager :
m_eventManager = libvlc_media_list_event_manager( m_internalPtr, m_exception );
m_exception.checkThrow();
initWatchedEvents();
}
MediaList::~MediaList()
{
}
void MediaList::initWatchedEvents()
{
libvlc_event_attach( m_eventManager, libvlc_MediaListItemAdded, callbacks, this, m_exception );
}
void MediaList::callbacks( const libvlc_event_t* event, void* ptr)
{
MediaList* self = reinterpret_cast< MediaList* >( ptr );
switch ( event->type )
{
case libvlc_MediaListItemAdded:
qDebug() << "Media list added";
break ;
default:
break ;
}
}
void MediaList::addMedia( Media* media )
{
MediaList::Locker lockMediaList( m_internalPtr );
libvlc_media_list_add_media( m_internalPtr, *media, m_exception );
m_exception.checkThrow();
}
void MediaList::setMediaPlayer( MediaPlayer* mp )
{
libvlc_media_list_player_set_media_player( m_listPlayer, *mp, m_exception );
}
MediaList::Locker::Locker( MediaList::internalPtr mediaList ) : m_mediaList( mediaList )
{
libvlc_media_list_lock( mediaList );
}
MediaList::Locker::~Locker()
{
libvlc_media_list_unlock( m_mediaList );
}
#ifndef VLCMEDIALIST_H
#define VLCMEDIALIST_H
#include "vlc/vlc.h"
#include "VLCException.h"
#include "VLCpp.hpp"
#include "VLCMediaPlayer.h"
namespace LibVLCpp
{
class MediaList : public Internal<libvlc_media_list_t>
{
public:
class Locker
{
public:
Locker( MediaList::internalPtr mediaList );
~Locker();
private:
MediaList::internalPtr m_mediaList;
};
MediaList();
~MediaList();
void addMedia( Media* media );
void setMediaPlayer( MediaPlayer* mp );
static void callbacks( const libvlc_event_t* event, void* self );
private:
void initWatchedEvents();
MediaPlayer* m_vlcMediaPlayer;
Exception m_exception;
libvlc_media_list_player_t* m_listPlayer;
libvlc_event_manager_t* m_eventManager;
};
}
#endif // VLCMEDIALIST_H
......@@ -32,7 +32,8 @@ SOURCES += src/main.cpp \
src/gui/Transcode.cpp \
src/InputMedia.cpp \
src/gui/Slider.cpp \
src/MetaDataManager.cpp
src/MetaDataManager.cpp \
src/LibVLCpp/VLCMediaList.cpp
HEADERS += src/gui/MainWindow.h \
src/gui/DockWidgetManager.h \
src/gui/LibraryWidget.h \
......@@ -56,7 +57,8 @@ HEADERS += src/gui/MainWindow.h \
src/gui/Transcode.h \
src/InputMedia.h \
src/gui/Slider.h \
src/MetaDataManager.h
src/MetaDataManager.h \
src/LibVLCpp/VLCMediaList.h
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \
......@@ -64,7 +66,7 @@ FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/LibraryWidget.ui \
src/gui/ui/About.ui \
src/gui/ui/Transcode.ui
FORMS +=
FORMS +=
TRANSLATIONS = ts/vlmc_es.ts \
ts/vlmc_fr.ts \
ts/vlmc_sv.ts
......
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