vlcpeer.cpp 3.33 KB
Newer Older
1
/*****************************************************************************
2
 * vlcpeer.cpp: scriptable peer descriptor
3 4
 *****************************************************************************
 * Copyright (C) 2002 VideoLAN
Sam Hocevar's avatar
Sam Hocevar committed
5
 * $Id: vlcpeer.cpp,v 1.9 2003/10/23 17:04:39 sam Exp $
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * Authors: Samuel Hocevar <sam@zoy.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
Sam Hocevar's avatar
Sam Hocevar committed
27 28
#include "config.h"

29 30
#include <vlc/vlc.h>

31 32 33 34 35
#ifdef DEBUG
/* We do not want to use nsDebug.h */
#   undef DEBUG
#endif

Sam Hocevar's avatar
Sam Hocevar committed
36 37 38
#ifdef HAVE_MOZILLA_CONFIG_H
#   include <mozilla-config.h>
#endif
39 40 41
#include <nsISupports.h>
#include <nsMemory.h>
#include <npapi.h>
42

Sam Hocevar's avatar
Sam Hocevar committed
43 44 45 46 47 48
#if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
#define XP_UNIX 1
#elif defined(XP_MACOSX)
#undef XP_UNIX
#endif

49 50 51 52 53
#include "vlcpeer.h"
#include "vlcplugin.h"

NS_IMPL_ISUPPORTS2( VlcPeer, VlcIntf, nsIClassInfo )

54 55 56
/*****************************************************************************
 * Scriptable peer constructor and destructor
 *****************************************************************************/
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
VlcPeer::VlcPeer()
{
    NS_INIT_ISUPPORTS();
}

VlcPeer::VlcPeer( VlcPlugin * plugin )
{
    NS_INIT_ISUPPORTS();
    p_plugin = plugin;
}

VlcPeer::~VlcPeer()
{
    ;
}

73 74 75 76 77 78 79 80 81 82 83
/*****************************************************************************
 * Scriptable peer methods
 *****************************************************************************/
void VlcPeer::Disable()
{
    p_plugin = NULL;
}

/*****************************************************************************
 * Scriptable peer plugin methods
 *****************************************************************************/
84 85 86 87
NS_IMETHODIMP VlcPeer::Play()
{
    if( p_plugin )
    {
88 89
        if( !p_plugin->b_stream && p_plugin->psz_target )
        {
gbazin's avatar
 
gbazin committed
90
            VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target, 0, 0,
Sam Hocevar's avatar
Sam Hocevar committed
91
                           PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
92 93 94
            p_plugin->b_stream = 1;
        }

Sam Hocevar's avatar
Sam Hocevar committed
95
        VLC_Play( p_plugin->i_vlc );
96 97 98 99 100 101 102 103
    }
    return NS_OK;
}

NS_IMETHODIMP VlcPeer::Pause()
{
    if( p_plugin )
    {
Sam Hocevar's avatar
Sam Hocevar committed
104
        VLC_Pause( p_plugin->i_vlc );
105 106 107 108 109 110 111 112
    }
    return NS_OK;
}

NS_IMETHODIMP VlcPeer::Stop()
{
    if( p_plugin )
    {
Sam Hocevar's avatar
Sam Hocevar committed
113
        VLC_Stop( p_plugin->i_vlc );
114 115 116 117 118 119 120 121 122
        p_plugin->b_stream = 0;
    }
    return NS_OK;
}

NS_IMETHODIMP VlcPeer::Fullscreen()
{
    if( p_plugin )
    {
123 124
#ifdef XP_MACOSX
#else
Sam Hocevar's avatar
Sam Hocevar committed
125
        VLC_FullScreen( p_plugin->i_vlc );
126
#endif
127 128 129 130
    }
    return NS_OK;
}