]> git.sesse.net Git - vlc/blob - mozilla/vlcpeer.cpp
* ALL: changes to the playlist_Add() and VLC_AddTarget() proto to include a list...
[vlc] / mozilla / vlcpeer.cpp
1 /*****************************************************************************
2  * vlcpeer.cpp: scriptable peer descriptor
3  *****************************************************************************
4  * Copyright (C) 2002 VideoLAN
5  * $Id: vlcpeer.cpp,v 1.6 2003/07/23 01:13:48 gbazin 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 <nsISupports.h>
30 #include <nsMemory.h>
31 #include <npapi.h>
32
33 #include "vlcpeer.h"
34 #include "vlcplugin.h"
35
36 NS_IMPL_ISUPPORTS2( VlcPeer, VlcIntf, nsIClassInfo )
37
38 /*****************************************************************************
39  * Scriptable peer constructor and destructor
40  *****************************************************************************/
41 VlcPeer::VlcPeer()
42 {
43     NS_INIT_ISUPPORTS();
44 }
45
46 VlcPeer::VlcPeer( VlcPlugin * plugin )
47 {
48     NS_INIT_ISUPPORTS();
49     p_plugin = plugin;
50 }
51
52 VlcPeer::~VlcPeer()
53 {
54     ;
55 }
56
57 /*****************************************************************************
58  * Scriptable peer methods
59  *****************************************************************************/
60 void VlcPeer::Disable()
61 {
62     p_plugin = NULL;
63 }
64
65 /*****************************************************************************
66  * Scriptable peer plugin methods
67  *****************************************************************************/
68 NS_IMETHODIMP VlcPeer::Play()
69 {
70     if( p_plugin )
71     {
72         if( !p_plugin->b_stream && p_plugin->psz_target )
73         {
74             VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target, 0, 0,
75                            PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
76             p_plugin->b_stream = 1;
77         }
78
79         VLC_Play( p_plugin->i_vlc );
80     }
81     return NS_OK;
82 }
83
84 NS_IMETHODIMP VlcPeer::Pause()
85 {
86     if( p_plugin )
87     {
88         VLC_Pause( p_plugin->i_vlc );
89     }
90     return NS_OK;
91 }
92
93 NS_IMETHODIMP VlcPeer::Stop()
94 {
95     if( p_plugin )
96     {
97         VLC_Stop( p_plugin->i_vlc );
98         p_plugin->b_stream = 0;
99     }
100     return NS_OK;
101 }
102
103 NS_IMETHODIMP VlcPeer::Fullscreen()
104 {
105     if( p_plugin )
106     {
107         VLC_FullScreen( p_plugin->i_vlc );
108     }
109     return NS_OK;
110 }
111