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 );
31 m_audio.setMediaPlayer( m_player );
34 MediaPlayer::MediaPlayer( Media &media )
36 m_player = libvlc_media_player_new_from_media( media.m_media );
37 m_audio.setMediaPlayer( m_player );
40 MediaPlayer::~MediaPlayer()
42 libvlc_media_player_release( m_player );
45 void MediaPlayer::setMedia( Media &media )
47 libvlc_media_player_set_media( m_player, media.m_media );
50 int MediaPlayer::isPlaying()
52 return libvlc_media_player_is_playing( m_player );
55 void MediaPlayer::play()
57 libvlc_media_player_play( m_player );
60 void MediaPlayer::pause()
62 libvlc_media_player_pause( m_player );
65 void MediaPlayer::stop()
67 libvlc_media_player_stop( m_player );
70 void MediaPlayer::setNSObject( void *drawable )
72 libvlc_media_player_set_nsobject( m_player, drawable );
75 void* MediaPlayer::nsobject()
77 return libvlc_media_player_get_nsobject( m_player );
80 void MediaPlayer::setAgl( uint32_t drawable )
82 libvlc_media_player_set_agl( m_player, drawable );
85 uint32_t MediaPlayer::agl()
87 return libvlc_media_player_get_agl( m_player );
90 void MediaPlayer::setXWindow( uint32_t drawable )
92 libvlc_media_player_set_xwindow( m_player, drawable );
95 uint32_t MediaPlayer::xwindow()
97 return libvlc_media_player_get_xwindow( m_player );
100 void MediaPlayer::setHwnd( void *drawable )
102 libvlc_media_player_set_hwnd( m_player, drawable );
105 void *MediaPlayer::hwnd()
107 return libvlc_media_player_get_hwnd( m_player );
110 int64_t MediaPlayer::lenght()
112 return libvlc_media_player_get_length( m_player );
115 int64_t MediaPlayer::time()
117 return libvlc_media_player_get_time( m_player );
120 void MediaPlayer::setTime( int64_t new_time )
122 libvlc_media_player_set_time( m_player, new_time );
125 float MediaPlayer::position()
127 return libvlc_media_player_get_position( m_player );
130 void MediaPlayer::setPosition( float position )
132 libvlc_media_player_set_position( m_player, position );
135 int MediaPlayer::chapter()
137 return libvlc_media_player_get_chapter( m_player );
140 int MediaPlayer::chapterCount()
142 return libvlc_media_player_get_chapter_count( m_player );
145 int MediaPlayer::chapterCount( int title )
147 return libvlc_media_player_get_chapter_count_for_title( m_player, title );
150 void MediaPlayer::setChapter( int title )
152 libvlc_media_player_set_chapter( m_player, title );
155 int MediaPlayer::willPlay()
157 return libvlc_media_player_will_play( m_player );
160 int MediaPlayer::title()
162 return libvlc_media_player_get_title( m_player );
165 int MediaPlayer::titleCount()
167 return libvlc_media_player_get_title_count( m_player );
170 void MediaPlayer::setTitle( int title )
172 libvlc_media_player_set_title( m_player, title );
175 void MediaPlayer::previousChapter()
177 libvlc_media_player_previous_chapter( m_player );
180 void MediaPlayer::nextChapter()
182 libvlc_media_player_next_chapter( m_player );
185 float MediaPlayer::rate()
187 return libvlc_media_player_get_rate( m_player );
190 void MediaPlayer::setRate( float rate )
192 libvlc_media_player_set_rate( m_player, rate );
195 libvlc_state_t MediaPlayer::state()
197 return libvlc_media_player_get_state( m_player );
200 float MediaPlayer::fps()
202 return libvlc_media_player_get_fps( m_player );
205 int MediaPlayer::hasVout()
207 return libvlc_media_player_has_vout( m_player );
210 int MediaPlayer::isSeekable()
212 return libvlc_media_player_is_seekable( m_player );
214 int MediaPlayer::canPause()
216 return libvlc_media_player_can_pause( m_player );
219 void MediaPlayer::nextFrame()
221 libvlc_media_player_next_frame( m_player );
224 void MediaPlayer::toggleFullscreen()
226 libvlc_toggle_fullscreen( m_player );
229 void MediaPlayer::enableFullscreen()
231 libvlc_set_fullscreen( m_player, 1 );
234 void MediaPlayer::disableFullscreen()
236 libvlc_set_fullscreen( m_player, 0 );
239 int MediaPlayer::fullscreen()
241 return libvlc_get_fullscreen( m_player );
244 Audio &MediaPlayer::audio()