1 /*****************************************************************************
2 * media_player.cpp: Represent a media player
3 *****************************************************************************
4 * Copyright (C) 2010 the VideoLAN team
7 * Authors: RĂ©mi Duraffort <ivoire@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "media_player.hpp"
25 #include "exception.hpp"
27 using namespace libvlc;
29 MediaPlayer::MediaPlayer( libVLC &libvlcInstance )
32 m_player = libvlc_media_player_new( libvlcInstance.instance(), &ex.ex );
35 MediaPlayer::MediaPlayer( Media &media )
38 m_player = libvlc_media_player_new_from_media( media.instance(), &ex.ex );
41 MediaPlayer::~MediaPlayer()
43 libvlc_media_player_release( m_player );
46 void MediaPlayer::setMedia( Media &media )
49 libvlc_media_player_set_media( m_player, media.instance(), &ex.ex );
52 int MediaPlayer::isPlaying()
55 return libvlc_media_player_is_playing( m_player, &ex.ex );
58 void MediaPlayer::play()
61 libvlc_media_player_play( m_player, &ex.ex );
64 void MediaPlayer::pause()
67 libvlc_media_player_pause( m_player, &ex.ex );
70 void MediaPlayer::stop()
73 libvlc_media_player_stop( m_player, &ex.ex );
76 void MediaPlayer::setNSObject( void *drawable )
79 libvlc_media_player_set_nsobject( m_player, drawable, &ex.ex );
82 void* MediaPlayer::nsobject()
84 return libvlc_media_player_get_nsobject( m_player );
87 void MediaPlayer::setAgl( uint32_t drawable )
90 libvlc_media_player_set_agl( m_player, drawable, &ex.ex );
93 uint32_t MediaPlayer::agl()
95 return libvlc_media_player_get_agl( m_player );
98 void MediaPlayer::setXWindow( uint32_t drawable )
101 libvlc_media_player_set_xwindow( m_player, drawable, &ex.ex );
104 uint32_t MediaPlayer::xwindow()
106 return libvlc_media_player_get_xwindow( m_player );
109 void MediaPlayer::setHwnd( void *drawable )
112 libvlc_media_player_set_hwnd( m_player, drawable, &ex.ex );
115 void *MediaPlayer::hwnd()
117 return libvlc_media_player_get_hwnd( m_player );
120 int64_t MediaPlayer::lenght()
123 return libvlc_media_player_get_length( m_player, &ex.ex );
126 int64_t MediaPlayer::time()
129 return libvlc_media_player_get_time( m_player, &ex.ex );
132 void MediaPlayer::setTime( int64_t new_time )
135 libvlc_media_player_set_time( m_player, new_time, &ex.ex );
138 float MediaPlayer::position()
141 return libvlc_media_player_get_position( m_player, &ex.ex );
144 void MediaPlayer::setPosition( float position )
147 libvlc_media_player_set_position( m_player, position, &ex.ex );
150 int MediaPlayer::chapter()
153 return libvlc_media_player_get_chapter( m_player, &ex.ex );
156 int MediaPlayer::chapterCount()
159 return libvlc_media_player_get_chapter_count( m_player, &ex.ex );
162 int MediaPlayer::willPlay()
165 return libvlc_media_player_will_play( m_player, &ex.ex );