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"
26 using namespace libvlc;
28 MediaPlayer::MediaPlayer( libVLC &libvlcInstance )
30 m_player = libvlc_media_player_new( libvlcInstance.m_instance );
33 MediaPlayer::MediaPlayer( Media &media )
35 m_player = libvlc_media_player_new_from_media( media.m_media );
38 MediaPlayer::~MediaPlayer()
40 libvlc_media_player_release( m_player );
43 void MediaPlayer::setMedia( Media &media )
45 libvlc_media_player_set_media( m_player, media.m_media );
48 int MediaPlayer::isPlaying()
50 return libvlc_media_player_is_playing( m_player );
53 void MediaPlayer::play()
55 libvlc_media_player_play( m_player );
58 void MediaPlayer::pause()
60 libvlc_media_player_pause( m_player );
63 void MediaPlayer::stop()
65 libvlc_media_player_stop( m_player );
68 void MediaPlayer::setNSObject( void *drawable )
70 libvlc_media_player_set_nsobject( m_player, drawable );
73 void* MediaPlayer::nsobject()
75 return libvlc_media_player_get_nsobject( m_player );
78 void MediaPlayer::setAgl( uint32_t drawable )
80 libvlc_media_player_set_agl( m_player, drawable );
83 uint32_t MediaPlayer::agl()
85 return libvlc_media_player_get_agl( m_player );
88 void MediaPlayer::setXWindow( uint32_t drawable )
90 libvlc_media_player_set_xwindow( m_player, drawable );
93 uint32_t MediaPlayer::xwindow()
95 return libvlc_media_player_get_xwindow( m_player );
98 void MediaPlayer::setHwnd( void *drawable )
100 libvlc_media_player_set_hwnd( m_player, drawable );
103 void *MediaPlayer::hwnd()
105 return libvlc_media_player_get_hwnd( m_player );
108 int64_t MediaPlayer::lenght()
110 return libvlc_media_player_get_length( m_player );
113 int64_t MediaPlayer::time()
115 return libvlc_media_player_get_time( m_player );
118 void MediaPlayer::setTime( int64_t new_time )
120 libvlc_media_player_set_time( m_player, new_time );
123 float MediaPlayer::position()
125 return libvlc_media_player_get_position( m_player );
128 void MediaPlayer::setPosition( float position )
130 libvlc_media_player_set_position( m_player, position );
133 int MediaPlayer::chapter()
135 return libvlc_media_player_get_chapter( m_player );
138 int MediaPlayer::chapterCount()
140 return libvlc_media_player_get_chapter_count( m_player );
143 int MediaPlayer::chapterCount( int title )
145 return libvlc_media_player_get_chapter_count_for_title( m_player, title );
148 void MediaPlayer::setChapter( int title )
150 libvlc_media_player_set_chapter( m_player, title );
153 int MediaPlayer::willPlay()
155 return libvlc_media_player_will_play( m_player );
158 int MediaPlayer::title()
160 return libvlc_media_player_get_title( m_player );
163 int MediaPlayer::titleCount()
165 return libvlc_media_player_get_title_count( m_player );
168 void MediaPlayer::setTitle( int title )
170 libvlc_media_player_set_title( m_player, title );
173 void MediaPlayer::previousChapter()
175 libvlc_media_player_previous_chapter( m_player );
178 void MediaPlayer::nextChapter()
180 libvlc_media_player_next_chapter( m_player );
183 float MediaPlayer::rate()
185 return libvlc_media_player_get_rate( m_player );
188 void MediaPlayer::setRate( float rate )
190 libvlc_media_player_set_rate( m_player, rate );
193 libvlc_state_t MediaPlayer::state()
195 return libvlc_media_player_get_state( m_player );
198 float MediaPlayer::fps()
200 return libvlc_media_player_get_fps( m_player );
203 int MediaPlayer::hasVout()
205 return libvlc_media_player_has_vout( m_player );
208 int MediaPlayer::isSeekable()
210 return libvlc_media_player_is_seekable( m_player );
212 int MediaPlayer::canPause()
214 return libvlc_media_player_can_pause( m_player );
217 void MediaPlayer::nextFrame()
219 libvlc_media_player_next_frame( m_player );
222 void MediaPlayer::toggleFullscreen()
224 libvlc_toggle_fullscreen( m_player );
227 void MediaPlayer::enableFullscreen()
229 libvlc_set_fullscreen( m_player, 1 );
232 void MediaPlayer::disableFullscreen()
234 libvlc_set_fullscreen( m_player, 0 );
237 int MediaPlayer::fullscreen()
239 return libvlc_get_fullscreen( m_player );