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

Adding methods so that LibVLCpp::MediaPlayer knows what it's playing

parent 2de957bd
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
using namespace LibVLCpp; using namespace LibVLCpp;
Media::Media( const QString& filename ) Media::Media( const QString& filename )
: m_pixelBuffer( NULL ) : m_pixelBuffer( NULL ), m_fileName( filename )
{ {
m_internalPtr = libvlc_media_new( *(LibVLCpp::Instance::getInstance()), filename.toLocal8Bit(), m_ex ); m_internalPtr = libvlc_media_new( *(LibVLCpp::Instance::getInstance()), filename.toLocal8Bit(), m_ex );
CheckVlcppException(m_ex); CheckVlcppException(m_ex);
...@@ -108,3 +108,7 @@ uchar* Media::getPixelBuffer() ...@@ -108,3 +108,7 @@ uchar* Media::getPixelBuffer()
return m_pixelBuffer; return m_pixelBuffer;
} }
const QString& Media::getFileName() const
{
return m_fileName;
}
...@@ -51,6 +51,7 @@ namespace LibVLCpp ...@@ -51,6 +51,7 @@ namespace LibVLCpp
void outputInWindow(); void outputInWindow();
void setPixelBuffer( uchar* buffer ); void setPixelBuffer( uchar* buffer );
uchar* getPixelBuffer(); uchar* getPixelBuffer();
const QString& getFileName() const;
private: private:
...@@ -58,6 +59,7 @@ namespace LibVLCpp ...@@ -58,6 +59,7 @@ namespace LibVLCpp
Exception m_ex; Exception m_ex;
uchar* m_pixelBuffer; uchar* m_pixelBuffer;
QString m_fileName;
}; };
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
using namespace LibVLCpp; using namespace LibVLCpp;
MediaPlayer::MediaPlayer() MediaPlayer::MediaPlayer() : m_media( NULL )
{ {
m_internalPtr = libvlc_media_player_new( LibVLCpp::Instance::getInstance()->getInternalPtr(), m_ex ); m_internalPtr = libvlc_media_player_new( LibVLCpp::Instance::getInstance()->getInternalPtr(), m_ex );
CheckVlcppException( m_ex ); CheckVlcppException( m_ex );
...@@ -46,7 +46,7 @@ MediaPlayer::MediaPlayer() ...@@ -46,7 +46,7 @@ MediaPlayer::MediaPlayer()
libvlc_event_attach( p_em, libvlc_MediaPlayerLengthChanged, callbacks,this,m_ex ); libvlc_event_attach( p_em, libvlc_MediaPlayerLengthChanged, callbacks,this,m_ex );
} }
MediaPlayer::MediaPlayer( Media* media ) MediaPlayer::MediaPlayer( Media* media ) : m_media( media )
{ {
m_internalPtr = libvlc_media_player_new_from_media( media->getInternalPtr(), m_ex ); m_internalPtr = libvlc_media_player_new_from_media( media->getInternalPtr(), m_ex );
CheckVlcppException( m_ex ); CheckVlcppException( m_ex );
...@@ -259,3 +259,16 @@ bool MediaPlayer::hasVout() ...@@ -259,3 +259,16 @@ bool MediaPlayer::hasVout()
CheckVlcppException( m_ex ); CheckVlcppException( m_ex );
return res; return res;
} }
const QString& MediaPlayer::getLoadedFileName() const
{
return m_media->getFileName();
}
QString MediaPlayer::getLoadedMRL()
{
Media::internalPtr media = libvlc_media_player_get_media( m_internalPtr, m_ex );
CheckVlcppException( m_ex );
char* str = libvlc_media_get_mrl( media );
return QString( str );
}
...@@ -60,6 +60,8 @@ namespace LibVLCpp ...@@ -60,6 +60,8 @@ namespace LibVLCpp
float getFps(); float getFps();
void nextFrame(); void nextFrame();
bool hasVout(); bool hasVout();
const QString& getLoadedFileName() const;
QString getLoadedMRL();
private: private:
static void callbacks( const libvlc_event_t* event, void* self ); static void callbacks( const libvlc_event_t* event, void* self );
...@@ -67,6 +69,7 @@ namespace LibVLCpp ...@@ -67,6 +69,7 @@ namespace LibVLCpp
Exception m_ex; Exception m_ex;
libvlc_event_manager_t* p_em; libvlc_event_manager_t* p_em;
Media* m_media;
signals: signals:
void snapshotTaken(); void snapshotTaken();
......
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