]> git.sesse.net Git - vlc/blobdiff - mozilla/vlcpeer.cpp
FSF address change.
[vlc] / mozilla / vlcpeer.cpp
index f7078f42d926f746db13c67ef94eda5c56313d70..3c06a0395596102b058146cc36faba20ca1eb788 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * vlcpeer.cpp: scriptable peer descriptor
  *****************************************************************************
- * Copyright (C) 2002 VideoLAN
- * $Id: vlcpeer.cpp,v 1.9 2003/10/23 17:04:39 sam Exp $
+ * Copyright (C) 2002-2005 the VideoLAN team
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -18,7 +18,7 @@
  *
  * 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -128,3 +128,190 @@ NS_IMETHODIMP VlcPeer::Fullscreen()
     return NS_OK;
 }
 
+/* Set/Get vlc variables */
+NS_IMETHODIMP VlcPeer::Set_int_variable(const char *psz_var, PRInt64 value )
+{
+    vlc_value_t val;
+    val.i_int = value;
+    if( p_plugin )
+    {
+        VLC_VariableSet( p_plugin->i_vlc, psz_var, val );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Set_str_variable(const char *psz_var, const char *value )
+{
+    vlc_value_t val;
+    val.psz_string = strdup( value );
+    if( p_plugin )
+    {
+        VLC_VariableSet( p_plugin->i_vlc, psz_var, val );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Set_bool_variable(const char *psz_var, PRBool value )
+{
+    vlc_value_t val;
+    val.b_bool = value >= 1 ? VLC_TRUE : VLC_FALSE;
+    if( p_plugin )
+    {
+        VLC_VariableSet( p_plugin->i_vlc, psz_var, val );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Get_int_variable( const char *psz_var, PRInt64 *result )
+{
+    vlc_value_t val;
+    if( p_plugin )
+    {
+        fprintf(stderr, "Choppage de %s\n", psz_var );
+        VLC_VariableGet( p_plugin->i_vlc, psz_var, &val );
+        fprintf(stderr, "Valeur %i\n", val.i_int );
+        *result = (PRInt64)val.i_int;
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Get_bool_variable(  const char *psz_var,PRBool *result )
+{
+    vlc_value_t val;
+    if( p_plugin )
+    {
+        VLC_VariableGet( p_plugin->i_vlc, psz_var, &val );
+        *result = (PRBool)val.b_bool;
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Get_str_variable( const char *psz_var, char **result )
+{
+    vlc_value_t val;
+    if( p_plugin )
+    {
+        fprintf(stderr, "Choppage de %s\n", psz_var );
+        VLC_VariableGet( p_plugin->i_vlc, psz_var, &val );
+        if( val.psz_string )
+        {
+            *result = strdup( val.psz_string );
+        }
+        else
+        {
+            *result = strdup( "" );
+        }
+    }
+    return NS_OK;
+}
+
+/* Playlist control */
+NS_IMETHODIMP VlcPeer::Clear_playlist()
+{
+    if( p_plugin )
+    {
+        VLC_PlaylistClear( p_plugin->i_vlc );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Add_item( const char *psz_item )
+{
+     if( p_plugin )
+     {
+          VLC_AddTarget( p_plugin->i_vlc, psz_item, NULL, 0,
+                         PLAYLIST_APPEND, PLAYLIST_END);
+     }
+     return NS_OK;
+}
+
+
+NS_IMETHODIMP VlcPeer::Isplaying( PRBool *b_playing )
+{
+    if( p_plugin->i_vlc )
+    {
+        *b_playing = VLC_IsPlaying( p_plugin->i_vlc );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Get_position( PRInt64 *i_position )
+{
+    if( p_plugin->i_vlc )
+    {
+        *i_position = (PRInt64)VLC_PositionGet( p_plugin->i_vlc );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Get_time( PRInt64 *i_time )
+{
+    if( p_plugin->i_vlc )
+    {
+        *i_time = VLC_TimeGet( p_plugin->i_vlc );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Get_length( PRInt64 *i_length )
+{
+    if( p_plugin->i_vlc )
+    {
+        *i_length = VLC_LengthGet( p_plugin->i_vlc );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Seek( PRInt64 i_secs, PRInt64 b_relative )
+{
+    if( p_plugin->i_vlc )
+    {
+        VLC_TimeSet( p_plugin->i_vlc, i_secs, b_relative );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Next()
+{
+    if( p_plugin->i_vlc )
+    {
+        VLC_PlaylistNext( p_plugin->i_vlc);
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Previous()
+{
+    if( p_plugin->i_vlc )
+    {
+        VLC_PlaylistPrev( p_plugin->i_vlc );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Set_volume( PRInt64 i_volume )
+{
+    if( p_plugin->i_vlc )
+    {
+        VLC_VolumeSet( p_plugin->i_vlc, i_volume );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Get_volume( PRInt64 *i_volume )
+{
+    if( p_plugin->i_vlc )
+    {
+        *i_volume = VLC_VolumeGet( p_plugin->i_vlc );
+    }
+    return NS_OK;
+}
+
+NS_IMETHODIMP VlcPeer::Mute()
+{
+    if( p_plugin->i_vlc )
+    {
+        VLC_VolumeMute( p_plugin->i_vlc );
+    }
+    return NS_OK;
+}