]> git.sesse.net Git - vlc/blob - mozilla/vlcpeer.cpp
* ALL: the build mechanism now uses automake. See HACKING for more details.
[vlc] / mozilla / vlcpeer.cpp
1 /*****************************************************************************
2  * vlcpeer.cpp: scriptable peer descriptor
3  *****************************************************************************
4  * Copyright (C) 2002 VideoLAN
5  * $Id: vlcpeer.cpp,v 1.2 2002/09/30 11:05:41 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <vlc/vlc.h>
28
29 #include "npapi.h"
30 #include "vlcpeer.h"
31 #include "vlcplugin.h"
32
33 #include "nsMemory.h"
34
35 NS_IMPL_ISUPPORTS2( VlcPeer, VlcIntf, nsIClassInfo )
36
37 /*****************************************************************************
38  * Scriptable peer constructor and destructor
39  *****************************************************************************/
40 VlcPeer::VlcPeer()
41 {
42     NS_INIT_ISUPPORTS();
43 }
44
45 VlcPeer::VlcPeer( VlcPlugin * plugin )
46 {
47     NS_INIT_ISUPPORTS();
48     p_plugin = plugin;
49 }
50
51 VlcPeer::~VlcPeer()
52 {
53     ;
54 }
55
56 /*****************************************************************************
57  * Scriptable peer methods
58  *****************************************************************************/
59 void VlcPeer::Disable()
60 {
61     p_plugin = NULL;
62 }
63
64 /*****************************************************************************
65  * Scriptable peer plugin methods
66  *****************************************************************************/
67 NS_IMETHODIMP VlcPeer::Play()
68 {
69     if( p_plugin )
70     {
71         if( !p_plugin->b_stream && p_plugin->psz_target )
72         {
73             vlc_add_target_r( p_plugin->p_vlc, p_plugin->psz_target,
74                               PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
75             p_plugin->b_stream = 1;
76         }
77
78         vlc_play_r( p_plugin->p_vlc );
79     }
80     return NS_OK;
81 }
82
83 NS_IMETHODIMP VlcPeer::Pause()
84 {
85     if( p_plugin )
86     {
87         vlc_pause_r( p_plugin->p_vlc );
88     }
89     return NS_OK;
90 }
91
92 NS_IMETHODIMP VlcPeer::Stop()
93 {
94     if( p_plugin )
95     {
96         vlc_stop_r( p_plugin->p_vlc );
97         p_plugin->b_stream = 0;
98     }
99     return NS_OK;
100 }
101
102 NS_IMETHODIMP VlcPeer::Fullscreen()
103 {
104     if( p_plugin )
105     {
106         vlc_fullscreen_r( p_plugin->p_vlc );
107     }
108     return NS_OK;
109 }
110