Commit b92cb882 authored by Rémi Duraffort's avatar Rémi Duraffort

libvlcpp: fix the compilation and throw an exception if the constructor fail.

parent 2d5d0047
...@@ -28,8 +28,9 @@ using namespace libvlc; ...@@ -28,8 +28,9 @@ using namespace libvlc;
Media::Media( libVLC &libvlcInstance, const char *psz_mrl ) Media::Media( libVLC &libvlcInstance, const char *psz_mrl )
{ {
Exception ex; m_media = libvlc_media_new( libvlcInstance.m_instance, psz_mrl );
m_media = libvlc_media_new( libvlcInstance.m_instance, psz_mrl, &ex.ex ); if( !m_media )
throw libvlc_errmsg();
} }
Media::Media( const Media& original ) Media::Media( const Media& original )
...@@ -54,8 +55,7 @@ void Media::addOption( const char *ppsz_options, libvlc_media_option_t flag ) ...@@ -54,8 +55,7 @@ void Media::addOption( const char *ppsz_options, libvlc_media_option_t flag )
int64_t Media::duration() int64_t Media::duration()
{ {
Exception ex; return libvlc_media_get_duration( m_media );
return libvlc_media_get_duration( m_media, &ex.ex );
} }
int Media::isPreparsed() int Media::isPreparsed()
......
...@@ -28,6 +28,8 @@ using namespace libvlc; ...@@ -28,6 +28,8 @@ using namespace libvlc;
MediaPlayer::MediaPlayer( libVLC &libvlcInstance ) MediaPlayer::MediaPlayer( libVLC &libvlcInstance )
{ {
m_player = libvlc_media_player_new( libvlcInstance.m_instance ); m_player = libvlc_media_player_new( libvlcInstance.m_instance );
if( !m_player )
throw libvlc_errmsg();
m_audio.setMediaPlayer( m_player ); m_audio.setMediaPlayer( m_player );
m_video.setMediaPlayer( m_player ); m_video.setMediaPlayer( m_player );
} }
...@@ -35,7 +37,10 @@ MediaPlayer::MediaPlayer( libVLC &libvlcInstance ) ...@@ -35,7 +37,10 @@ MediaPlayer::MediaPlayer( libVLC &libvlcInstance )
MediaPlayer::MediaPlayer( Media &media ) MediaPlayer::MediaPlayer( Media &media )
{ {
m_player = libvlc_media_player_new_from_media( media.m_media ); m_player = libvlc_media_player_new_from_media( media.m_media );
if( !m_player )
throw libvlc_errmsg();
m_audio.setMediaPlayer( m_player ); m_audio.setMediaPlayer( m_player );
m_video.setMediaPlayer( m_player );
} }
MediaPlayer::~MediaPlayer() MediaPlayer::~MediaPlayer()
......
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