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 )
31 m_player = libvlc_media_player_new( libvlcInstance.m_instance );
34 MediaPlayer::MediaPlayer( Media &media )
36 m_player = libvlc_media_player_new_from_media( media.m_media );
39 MediaPlayer::~MediaPlayer()
41 libvlc_media_player_release( m_player );
44 void MediaPlayer::setMedia( Media &media )
46 libvlc_media_player_set_media( m_player, media.m_media );
49 int MediaPlayer::isPlaying()
51 return libvlc_media_player_is_playing( m_player );
54 void MediaPlayer::play()
56 libvlc_media_player_play( m_player );
59 void MediaPlayer::pause()
61 libvlc_media_player_pause( m_player );
64 void MediaPlayer::stop()
66 libvlc_media_player_stop( m_player );
69 void MediaPlayer::setNSObject( void *drawable )
71 libvlc_media_player_set_nsobject( m_player, drawable );
74 void* MediaPlayer::nsobject()
76 return libvlc_media_player_get_nsobject( m_player );
79 void MediaPlayer::setAgl( uint32_t drawable )
81 libvlc_media_player_set_agl( m_player, drawable );
84 uint32_t MediaPlayer::agl()
86 return libvlc_media_player_get_agl( m_player );
89 void MediaPlayer::setXWindow( uint32_t drawable )
91 libvlc_media_player_set_xwindow( m_player, drawable );
94 uint32_t MediaPlayer::xwindow()
96 return libvlc_media_player_get_xwindow( m_player );
99 void MediaPlayer::setHwnd( void *drawable )
101 libvlc_media_player_set_hwnd( m_player, drawable );
104 void *MediaPlayer::hwnd()
106 return libvlc_media_player_get_hwnd( m_player );
109 int64_t MediaPlayer::lenght()
111 return libvlc_media_player_get_length( m_player );
114 int64_t MediaPlayer::time()
116 return libvlc_media_player_get_time( m_player );
119 void MediaPlayer::setTime( int64_t new_time )
121 libvlc_media_player_set_time( m_player, new_time );
124 float MediaPlayer::position()
126 return libvlc_media_player_get_position( m_player );
129 void MediaPlayer::setPosition( float position )
131 libvlc_media_player_set_position( m_player, position );
134 int MediaPlayer::chapter()
136 return libvlc_media_player_get_chapter( m_player );
139 int MediaPlayer::chapterCount()
141 return libvlc_media_player_get_chapter_count( m_player );
144 int MediaPlayer::chapterCount( int title )
146 return libvlc_media_player_get_chapter_count_for_title( m_player, title );
149 void MediaPlayer::setChapter( int title )
151 libvlc_media_player_set_chapter( m_player, title );
154 int MediaPlayer::willPlay()
156 return libvlc_media_player_will_play( m_player );
159 int MediaPlayer::title()
161 return libvlc_media_player_get_title( m_player );
164 int MediaPlayer::titleCount()
166 return libvlc_media_player_get_title_count( m_player );
169 void MediaPlayer::setTitle( int title )
171 libvlc_media_player_set_title( m_player, title );
174 void MediaPlayer::previousChapter()
176 libvlc_media_player_previous_chapter( m_player );
179 void MediaPlayer::nextChapter()
181 libvlc_media_player_next_chapter( m_player );
184 float MediaPlayer::rate()
186 return libvlc_media_player_get_rate( m_player );
189 void MediaPlayer::setRate( float rate )
191 libvlc_media_player_set_rate( m_player, rate );
194 libvlc_state_t MediaPlayer::state()
196 return libvlc_media_player_get_state( m_player );
199 float MediaPlayer::fps()
201 return libvlc_media_player_get_fps( m_player );
204 int MediaPlayer::hasVout()
206 return libvlc_media_player_has_vout( m_player );
209 int MediaPlayer::isSeekable()
211 return libvlc_media_player_is_seekable( m_player );
213 int MediaPlayer::canPause()
215 return libvlc_media_player_can_pause( m_player );
218 void MediaPlayer::nextFrame()
220 libvlc_media_player_next_frame( m_player );
223 void MediaPlayer::toggleFullscreen()
226 libvlc_toggle_fullscreen( m_player, &ex.ex );
229 void MediaPlayer::enableFullscreen()
232 libvlc_set_fullscreen( m_player, 1, &ex.ex );
235 void MediaPlayer::disableFullscreen()
238 libvlc_set_fullscreen( m_player, 0, &ex.ex );
241 int MediaPlayer::fullscreen()
244 return libvlc_get_fullscreen( m_player, &ex.ex );