]> git.sesse.net Git - vlc/blob - bindings/libvlcpp/src/media_player.cpp
libvlcpp: getSomething => something
[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     Exception ex;
32     m_player = libvlc_media_player_new( libvlcInstance.instance(), &ex.ex );
33 }
34
35 MediaPlayer::MediaPlayer( Media &media )
36 {
37     Exception ex;
38     m_player = libvlc_media_player_new_from_media( media.instance(), &ex.ex );
39 }
40
41 MediaPlayer::~MediaPlayer()
42 {
43     libvlc_media_player_release( m_player );
44 }
45
46 void MediaPlayer::setMedia( Media &media )
47 {
48     Exception ex;
49     libvlc_media_player_set_media( m_player, media.instance(), &ex.ex );
50 }
51
52 int MediaPlayer::isPlaying()
53 {
54     Exception ex;
55     return libvlc_media_player_is_playing( m_player, &ex.ex );
56 }
57
58 void MediaPlayer::play()
59 {
60     Exception ex;
61     libvlc_media_player_play( m_player, &ex.ex );
62 }
63
64 void MediaPlayer::pause()
65 {
66     Exception ex;
67     libvlc_media_player_pause( m_player, &ex.ex );
68 }
69
70 void MediaPlayer::stop()
71 {
72     Exception ex;
73     libvlc_media_player_stop( m_player, &ex.ex );
74 }
75
76 void MediaPlayer::setNSObject( void *drawable )
77 {
78     Exception ex;
79     libvlc_media_player_set_nsobject( m_player, drawable, &ex.ex );
80 }
81
82 void* MediaPlayer::nsobject()
83 {
84     return libvlc_media_player_get_nsobject( m_player );
85 }
86
87 void MediaPlayer::setAgl( uint32_t drawable )
88 {
89     Exception ex;
90     libvlc_media_player_set_agl( m_player, drawable, &ex.ex );
91 }
92
93 uint32_t MediaPlayer::agl()
94 {
95     return libvlc_media_player_get_agl( m_player );
96 }
97
98 void MediaPlayer::setXWindow( uint32_t drawable )
99 {
100     Exception ex;
101     libvlc_media_player_set_xwindow( m_player, drawable, &ex.ex );
102 }
103
104 uint32_t MediaPlayer::xwindow()
105 {
106     return libvlc_media_player_get_xwindow( m_player );
107 }
108
109 void MediaPlayer::setHwnd( void *drawable )
110 {
111     Exception ex;
112     libvlc_media_player_set_hwnd( m_player, drawable, &ex.ex );
113 }
114
115 void *MediaPlayer::hwnd()
116 {
117     return libvlc_media_player_get_hwnd( m_player );
118 }
119
120 int64_t MediaPlayer::lenght()
121 {
122     Exception ex;
123     return libvlc_media_player_get_length( m_player, &ex.ex );
124 }
125
126 int64_t MediaPlayer::time()
127 {
128     Exception ex;
129     return libvlc_media_player_get_time( m_player, &ex.ex );
130 }
131
132 void MediaPlayer::setTime( int64_t new_time )
133 {
134     Exception ex;
135     libvlc_media_player_set_time( m_player, new_time, &ex.ex );
136 }
137
138 float MediaPlayer::position()
139 {
140     Exception ex;
141     return libvlc_media_player_get_position( m_player, &ex.ex );
142 }
143
144 void MediaPlayer::setPosition( float position )
145 {
146     Exception ex;
147     libvlc_media_player_set_position( m_player, position, &ex.ex );
148 }
149
150 int MediaPlayer::chapter()
151 {
152     Exception ex;
153     return libvlc_media_player_get_chapter( m_player, &ex.ex );
154 }
155
156 int MediaPlayer::chapterCount()
157 {
158     Exception ex;
159     return libvlc_media_player_get_chapter_count( m_player, &ex.ex );
160 }
161
162 int MediaPlayer::willPlay()
163 {
164     Exception ex;
165     return libvlc_media_player_will_play( m_player, &ex.ex );
166 }
167