1 /*****************************************************************************
2 * vlcpeer.cpp: scriptable peer descriptor
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
7 * Authors: Samuel Hocevar <sam@zoy.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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
32 /* We do not want to use nsDebug.h */
36 #ifdef HAVE_MOZILLA_CONFIG_H
37 # include <mozilla-config.h>
39 #include <nsISupports.h>
43 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
45 #elif defined(XP_MACOSX)
50 #include "vlcplugin.h"
52 NS_IMPL_ISUPPORTS2( VlcPeer, VlcIntf, nsIClassInfo )
54 /*****************************************************************************
55 * Scriptable peer constructor and destructor
56 *****************************************************************************/
62 VlcPeer::VlcPeer( VlcPlugin * plugin )
73 /*****************************************************************************
74 * Scriptable peer methods
75 *****************************************************************************/
76 void VlcPeer::Disable()
81 /*****************************************************************************
82 * Scriptable peer plugin methods
83 *****************************************************************************/
84 NS_IMETHODIMP VlcPeer::Play()
88 if( !p_plugin->b_stream && p_plugin->psz_target )
90 VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target, 0, 0,
91 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
92 p_plugin->b_stream = 1;
95 VLC_Play( p_plugin->i_vlc );
100 NS_IMETHODIMP VlcPeer::Pause()
104 VLC_Pause( p_plugin->i_vlc );
109 NS_IMETHODIMP VlcPeer::Stop()
113 VLC_Stop( p_plugin->i_vlc );
114 p_plugin->b_stream = 0;
119 NS_IMETHODIMP VlcPeer::Fullscreen()
125 VLC_FullScreen( p_plugin->i_vlc );
132 /* Playlist control */
133 NS_IMETHODIMP VlcPeer::Clear_playlist()
137 VLC_PlaylistClear( p_plugin->i_vlc );
142 NS_IMETHODIMP VlcPeer::Add_item( const char *psz_item )
146 VLC_AddTarget( p_plugin->i_vlc, psz_item, NULL, 0,
147 PLAYLIST_APPEND, PLAYLIST_END);
153 NS_IMETHODIMP VlcPeer::Isplaying( PRBool *b_playing )
155 if( p_plugin->i_vlc )
157 *b_playing = VLC_IsPlaying( p_plugin->i_vlc );
162 NS_IMETHODIMP VlcPeer::Get_position( PRInt64 *i_position )
164 if( p_plugin->i_vlc )
166 *i_position = VLC_PositionGet( p_plugin->i_vlc );
171 NS_IMETHODIMP VlcPeer::Get_time( PRInt64 *i_time )
173 if( p_plugin->i_vlc )
175 *i_time = VLC_TimeGet( p_plugin->i_vlc );
180 NS_IMETHODIMP VlcPeer::Get_length( PRInt64 *i_length )
182 if( p_plugin->i_vlc )
184 *i_length = VLC_LengthGet( p_plugin->i_vlc );
189 NS_IMETHODIMP VlcPeer::Seek( PRInt64 i_secs, PRInt64 b_relative )
191 if( p_plugin->i_vlc )
193 VLC_TimeSet( p_plugin->i_vlc, i_secs, b_relative );
198 NS_IMETHODIMP VlcPeer::Next()
200 if( p_plugin->i_vlc )
202 VLC_PlaylistNext( p_plugin->i_vlc);
207 NS_IMETHODIMP VlcPeer::Previous()
209 if( p_plugin->i_vlc )
211 VLC_PlaylistPrev( p_plugin->i_vlc );
216 NS_IMETHODIMP VlcPeer::Set_volume( PRInt64 i_volume )
218 if( p_plugin->i_vlc )
220 VLC_VolumeSet( p_plugin->i_vlc, i_volume );
225 NS_IMETHODIMP VlcPeer::Get_volume( PRInt64 *i_volume )
227 if( p_plugin->i_vlc )
229 *i_volume = VLC_VolumeGet( p_plugin->i_vlc );
234 NS_IMETHODIMP VlcPeer::Mute()
236 if( p_plugin->i_vlc )
238 VLC_VolumeMute( p_plugin->i_vlc );