]> git.sesse.net Git - vlc/blob - bindings/libvlcpp/src/media_player.cpp
cc4401a97e70fce956fe31c67b02cc50e3719a04
[vlc] / bindings / libvlcpp / src / media_player.cpp
1 /*****************************************************************************
2  * media_player.cpp: Represent a media player
3  *****************************************************************************
4  * Copyright (C) 2010 the VideoLAN team
5  * $Id$
6  *
7  * Authors: RĂ©mi Duraffort <ivoire@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include "media_player.hpp"
25 #include "exception.hpp"
26
27 using namespace libvlc;
28
29 MediaPlayer::MediaPlayer( libVLC &libvlcInstance )
30 {
31     m_player = libvlc_media_player_new( libvlcInstance.m_instance );
32 }
33
34 MediaPlayer::MediaPlayer( Media &media )
35 {
36     m_player = libvlc_media_player_new_from_media( media.m_media );
37 }
38
39 MediaPlayer::~MediaPlayer()
40 {
41     libvlc_media_player_release( m_player );
42 }
43
44 void MediaPlayer::setMedia( Media &media )
45 {
46     libvlc_media_player_set_media( m_player, media.m_media );
47 }
48
49 int MediaPlayer::isPlaying()
50 {
51     return libvlc_media_player_is_playing( m_player );
52 }
53
54 void MediaPlayer::play()
55 {
56     libvlc_media_player_play( m_player );
57 }
58
59 void MediaPlayer::pause()
60 {
61     libvlc_media_player_pause( m_player );
62 }
63
64 void MediaPlayer::stop()
65 {
66     libvlc_media_player_stop( m_player );
67 }
68
69 void MediaPlayer::setNSObject( void *drawable )
70 {
71     libvlc_media_player_set_nsobject( m_player, drawable );
72 }
73
74 void* MediaPlayer::nsobject()
75 {
76     return libvlc_media_player_get_nsobject( m_player );
77 }
78
79 void MediaPlayer::setAgl( uint32_t drawable )
80 {
81     libvlc_media_player_set_agl( m_player, drawable );
82 }
83
84 uint32_t MediaPlayer::agl()
85 {
86     return libvlc_media_player_get_agl( m_player );
87 }
88
89 void MediaPlayer::setXWindow( uint32_t drawable )
90 {
91     libvlc_media_player_set_xwindow( m_player, drawable );
92 }
93
94 uint32_t MediaPlayer::xwindow()
95 {
96     return libvlc_media_player_get_xwindow( m_player );
97 }
98
99 void MediaPlayer::setHwnd( void *drawable )
100 {
101     libvlc_media_player_set_hwnd( m_player, drawable );
102 }
103
104 void *MediaPlayer::hwnd()
105 {
106     return libvlc_media_player_get_hwnd( m_player );
107 }
108
109 int64_t MediaPlayer::lenght()
110 {
111     return libvlc_media_player_get_length( m_player );
112 }
113
114 int64_t MediaPlayer::time()
115 {
116     return libvlc_media_player_get_time( m_player );
117 }
118
119 void MediaPlayer::setTime( int64_t new_time )
120 {
121     libvlc_media_player_set_time( m_player, new_time );
122 }
123
124 float MediaPlayer::position()
125 {
126     return libvlc_media_player_get_position( m_player );
127 }
128
129 void MediaPlayer::setPosition( float position )
130 {
131     libvlc_media_player_set_position( m_player, position );
132 }
133
134 int MediaPlayer::chapter()
135 {
136     return libvlc_media_player_get_chapter( m_player );
137 }
138
139 int MediaPlayer::chapterCount()
140 {
141     return libvlc_media_player_get_chapter_count( m_player );
142 }
143
144 int MediaPlayer::chapterCount( int title )
145 {
146     return libvlc_media_player_get_chapter_count_for_title( m_player, title );
147 }
148
149 void MediaPlayer::setChapter( int title )
150 {
151     libvlc_media_player_set_chapter( m_player, title );
152 }
153
154 int MediaPlayer::willPlay()
155 {
156     return libvlc_media_player_will_play( m_player );
157 }
158
159 int MediaPlayer::title()
160 {
161     return libvlc_media_player_get_title( m_player );
162 }
163
164 int MediaPlayer::titleCount()
165 {
166     return libvlc_media_player_get_title_count( m_player );
167 }
168
169 void MediaPlayer::setTitle( int title )
170 {
171     libvlc_media_player_set_title( m_player, title );
172 }
173
174 void MediaPlayer::previousChapter()
175 {
176     libvlc_media_player_previous_chapter( m_player );
177 }
178
179 void MediaPlayer::nextChapter()
180 {
181     libvlc_media_player_next_chapter( m_player );
182 }
183
184 float MediaPlayer::rate()
185 {
186     return libvlc_media_player_get_rate( m_player );
187 }
188
189 void MediaPlayer::setRate( float rate )
190 {
191     libvlc_media_player_set_rate( m_player, rate );
192 }
193
194 libvlc_state_t MediaPlayer::state()
195 {
196     return libvlc_media_player_get_state( m_player );
197 }
198
199 float MediaPlayer::fps()
200 {
201     return libvlc_media_player_get_fps( m_player );
202 }
203
204 int MediaPlayer::hasVout()
205 {
206     return libvlc_media_player_has_vout( m_player );
207 }
208
209 int MediaPlayer::isSeekable()
210 {
211     return libvlc_media_player_is_seekable( m_player );
212 }
213 int MediaPlayer::canPause()
214 {
215     return libvlc_media_player_can_pause( m_player );
216 }
217
218 void MediaPlayer::nextFrame()
219 {
220     libvlc_media_player_next_frame( m_player );
221 }
222
223 void MediaPlayer::toggleFullscreen()
224 {
225     Exception ex;
226     libvlc_toggle_fullscreen( m_player, &ex.ex );
227 }
228
229 void MediaPlayer::enableFullscreen()
230 {
231     Exception ex;
232     libvlc_set_fullscreen( m_player, 1, &ex.ex );
233 }
234
235 void MediaPlayer::disableFullscreen()
236 {
237     Exception ex;
238     libvlc_set_fullscreen( m_player, 0, &ex.ex );
239 }
240
241 int MediaPlayer::fullscreen()
242 {
243     Exception ex;
244     return libvlc_get_fullscreen( m_player, &ex.ex );
245 }