FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour clase VLC para crear un player - algunos problemas
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Tue Oct 16, 2018 08:15 PM
no, realmente no estoy interesado en eso. :-(
siguiendo con el api, esto es lo que tengo hasta el momento. no me muestra nada.
https://progur.com/2017/06/how-to-use-vlc-api-in-c.html
bcc32 -I.\include -L.\lib libvlc.lib myplayer3.c
Code (fw): Select all Collapse
#include <windows.h>
#include <stdio.h>
#include <vlc.h>
#include <stdlib.h>

int main(void)
{
    libvlc_instance_t     *my_instance;
    libvlc_media_t        *my_media_file;
    libvlc_media_player_t *my_player;

    //instance
    my_instance = libvlc_new(0, NULL);

    if(my_instance == NULL) {
        return(-1);
    }

    //use a media file
    my_media_file = libvlc_media_new_path(my_instance, "video.mp4");

    // Create player
    my_player = libvlc_media_player_new_from_media(my_media_file);

    // Start playing
    libvlc_media_player_play(my_player);

    Sleep(5);

    libvlc_media_release(my_media_file); 
    libvlc_media_player_release(my_player);
    libvlc_release(my_instance);

    return(0);
}
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 34
Joined: Tue Mar 20, 2012 11:06 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Fri Oct 10, 2025 12:46 AM
carlos vargas wrote:
por eso me gustaria usar el api en lugar de activex (lo cual limita a windows como SO), ya que con productos tales como fivelinux podria usar linux como sistema operativo, lo cual es mi mayor interes.
un programa de rokonola digital para linux y windows.

salu2
carlos vargas
Hola Carlos: te puedo hacer una pregunta en forma privada sobre libvlc.dll si es que lo has usado
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Sat Oct 11, 2025 05:05 AM
Veamos :-)
Lamentablemente este proyecto que tenía muy, muy adelantado hace años, perdí los fuente junto con un equipo :-( intente hasta 2 o 3 veces rehacerlo de nuevo pero fracase y nunca alcance el avance de la primera vez.
Pero si en algo te puedo asistir lo haré...
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 34
Joined: Tue Mar 20, 2012 11:06 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Sat Oct 11, 2025 04:29 PM
carlos vargas wrote: Veamos :-)
Lamentablemente este proyecto que tenía muy, muy adelantado hace años, perdí los fuente junto con un equipo :-( intente hasta 2 o 3 veces rehacerlo de nuevo pero fracase y nunca alcance el avance de la primera vez.
Pero si en algo te puedo asistir lo haré...
Hola Carlos 👋

lamento la perdida del proyecto... te comento que estos dias tuve un avance importante con la libreria LIBVLC, estuve intentando crear un LibLibvlc.a de libvlc.dll pero en las 2 tengo un problema que no me regresa el puntero de LibVLCNEW() al cual estoy resolviendo mediante ejemplos en Delphi ya que trabaje un tiempo programando en Turbo Pascal y estoy traduciendo el codigo
Saludos
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Sat Oct 11, 2025 09:22 PM

Déjame buscar lo que tengo y lo pongo acá, eso lo tengo hecho sin problemas.

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 34
Joined: Tue Mar 20, 2012 11:06 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Sun Oct 12, 2025 01:16 AM
carlos vargas wrote: Déjame buscar lo que tengo y lo pongo acá, eso lo tengo hecho sin problemas.
ya tengo un wrapper minimo funcional de libvlc.dll, libvlc es dificil de implementar por mi parte, ya obtuve el puntero necesario para seguir, es que tengo 2 camaras IP PTZ las cual la aplicacion de windows es muy basica pero no me permite ver las 2 a la vez, asi que tuve que aprender a usar Socket en harbour y conectarme a ella mediante el protocolo RTSP . eso ya lo tengo probado, ahora con LibVLC voy a capturar el flujo de audio y video que viene sobre el protocolo RTP y mostrarlo en una ventana que ya hice en HMG (trabajo sobre minigui).
----------------------------------------------------------------------
Crear el Wrapper de Libvlc.dll y ver las funciones expuestas del mismo
----------------------------------------------------------------------
del /Q vlcwrapper.o vlcwrapper.dll 2>nul || true
🧹
🧹 Limpieza completa.
🧹



g++ -std=c++17 -O2 -Wall -Wextra -D_WIN32_WINNT=0x0601 -IC:\vlc-3.0.21\sdk\include -c vlcwrapper.cpp -o vlcwrapper.o
g++ -std=c++17 -O2 -Wall -Wextra -D_WIN32_WINNT=0x0601 vlcwrapper.o -LC:\vlc-3.0.21\sdk\lib -shared -llibvlc -llibvlccore -o vlcwrapper.dll
✅
✅ Compilación completada: vlcwrapper.dll

✅ vlcwrapper.dll con las funciones (ƒ) exportadas abajo


1 0 00001860 vlc_close
2 1 00001540 vlc_init
3 2 00001730 vlc_play
4 3 00001840 vlc_stop
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Mon Oct 13, 2025 05:32 AM
myvlc.c
#include <windows.h>
#include <vlc/vlc.h>
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "hbapistr.h"
#include "hbapicls.h"

//------------------------------------------------------------------------------
/**
* libvlc_instance_t * libvlc_new( int argc, const char *const * argv )
* Create and initialize a libvlc instance.
* Parameters
* argc   the number of arguments (should be 0)
* argv   list of arguments (should be NULL)
* Returns
* the libvlc instance or NULL in case of error
*/
HB_FUNC( MYVLC_NEW )
{
   libvlc_instance_t* hVlc = libvlc_new( 0, NULL );
   if( hVlc )
   {
      hb_retptr( hVlc );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_media_t *libvlc_media_new_path(
 *                                  libvlc_instance_t *p_instance,
 *                                  const char *path );
 * Create a media for a certain file path.
 *
 * \see libvlc_media_release
 *
 * \param p_instance the instance
 * \param path local filesystem path
 * \return the newly created media or NULL on error
 */
HB_FUNC( MYVLC_MEDIA_NEW )
{
   libvlc_instance_t *hVlc = (libvlc_instance_t *) hb_parptr( 1 );
   if( hVlc )
   {
      void *pstrFileName = NULL;
      hb_retptr( (void *) libvlc_media_new_path( hVlc, hb_parstr_utf8( 2, &pstrFileName, NULL ) ) );
      hb_strfree( pstrFileName );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_media_player_t * libvlc_media_player_new( libvlc_instance_t *p_libvlc_instance );
 * Create an empty Media Player object
 *
 * \param p_libvlc_instance the libvlc instance in which the Media Player
 *        should be created.
 * \return a new media player object, or NULL on error.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_NEW )
{
   libvlc_instance_t *hVlc = (libvlc_instance_t *) hb_parptr( 1 );
   if( hVlc )
   {
      libvlc_media_player_t *hMediaPlayer;
      hMediaPlayer = libvlc_media_player_new( hVlc );
      hb_retptr( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_media_player_t * libvlc_media_player_new_from_media( libvlc_media_t *p_md );
 * Create a Media Player object from a Media
 *
 * \param p_md the media. Afterwards the p_md can be safely
 *        destroyed.
 * \return a new media player object, or NULL on error.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_NEW_FROM_MEDIA )
{
   libvlc_media_t *hMedia = (libvlc_media_t *) hb_parptr( 1 );
   if( hMedia )
   {
      libvlc_media_player_t *hMediaPlayer;
      hMediaPlayer = libvlc_media_player_new_from_media( hMedia );
      hb_retptr( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_media( libvlc_media_player_t *p_mi,
 *                                                libvlc_media_t *p_md );
 * Set the media that will be used by the media_player. If any,
 * previous md will be released.
 *
 * \param p_mi the Media Player
 * \param p_md the Media. Afterwards the p_md can be safely
 *        destroyed.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_MEDIA )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   libvlc_media_t *hMedia = (libvlc_media_t *) hb_parptr( 2 );
   if( hMediaPlayer && hMedia )
   {
      libvlc_media_player_set_media( hMediaPlayer, hMedia );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_hwnd ( libvlc_media_player_t *p_mi, void *drawable );
 * Set a Win32/Win64 API window handle (HWND) where the media player should
 * render its video output. If LibVLC was built without Win32/Win64 API output
 * support, then this has no effects.
 *
 * \warning the HWND must have the WS_CLIPCHILDREN set in its style.
 *
 * \param p_mi the Media Player
 * \param drawable windows handle of the drawable
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_HWND )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   HWND hWnd = (HWND) hb_parnl( 2 );
   if( hMediaPlayer && hWnd )
   {
      libvlc_media_player_set_hwnd( hMediaPlayer, hWnd );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void *libvlc_media_player_get_hwnd ( libvlc_media_player_t *p_mi );
 * Get the Windows API window handle (HWND) previously set with
 * libvlc_media_player_set_hwnd(). The handle will be returned even if LibVLC
 * is not currently outputting any video to it.
 *
 * \param p_mi the Media Player
 * \return a window handle or NULL if there are none.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_HWND )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnl( (HB_LONG) libvlc_media_player_get_hwnd( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * Is the player able to play
 * LIBVLC_API int libvlc_media_player_will_play( libvlc_media_player_t *p_mi );
 *
 * \param p_mi the Media Player
 * \return boolean
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_WILL_PLAY )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_media_player_will_play( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_media_player_play ( libvlc_media_player_t *p_mi );
 * Play
 *
 * \param p_mi the Media Player
 * \return 0 if playback started (and was already started), or -1 on error.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_PLAY )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_media_player_play( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_media_player_is_playing ( libvlc_media_player_t *p_mi );
 * is_playing
 *
 * \param p_mi the Media Player
 * \return 1 if the media player is playing, 0 otherwise
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_ISPLAYING )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
       hb_retl( (HB_BOOL) libvlc_media_player_is_playing( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi );
 * Can this media player be paused?
 *
 * \param p_mi the media player
 * \return true if the media player can pause
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_CAN_PAUSE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_media_player_can_pause( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_pause ( libvlc_media_player_t *mp,
 *                                                 int do_pause );
 * Pause or resume (no effect if there is no media)
 *
 * \param mp the Media Player
 * \param do_pause play/resume if zero, pause if non-zero
 * \version LibVLC 1.1.1 or later
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_PAUSE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_set_pause( hMediaPlayer, (int) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_pause ( libvlc_media_player_t *p_mi );
 * Toggle pause (no effect if there is no media)
 *
 * \param p_mi the Media Player
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_PAUSE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_pause( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_stop ( libvlc_media_player_t *p_mi );
 * Stop (no effect if there is no media)
 *
 * \param p_mi the Media Player
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_STOP )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_stop( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_time_t libvlc_media_player_get_length( libvlc_media_player_t *p_mi );
 * Get the current movie length (in ms).
 *
 * \param p_mi the Media Player
 * \return the movie length (in ms), or -1 if there is no media.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_LENGTH )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnl( (HB_ULONG) libvlc_media_player_get_length( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t *p_mi );
 * Get the current movie time (in ms).
 *
 * \param p_mi the Media Player
 * \return the movie time (in ms), or -1 if there is no media.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_TIME )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnl( (HB_ULONG) libvlc_media_player_get_time( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API float libvlc_media_player_get_position( libvlc_media_player_t *p_mi );
 * Get movie position as percentage between 0.0 and 1.0.
 *
 * \param p_mi the Media Player
 * \return movie position, or -1. in case of error
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_POSITION )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnd( (double) libvlc_media_player_get_position( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_position( libvlc_media_player_t *p_mi, float f_pos );
 * Set movie position as percentage between 0.0 and 1.0.
 * This has no effect if playback is not enabled.
 * This might not work depending on the underlying input format and protocol.
 *
 * \param p_mi the Media Player
 * \param f_pos the position
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_POSITION )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_set_position( hMediaPlayer, (float) hb_parnd( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_set_fullscreen( libvlc_media_player_t *p_mi, int b_fullscreen );
 * Enable or disable fullscreen.
 *
 * @warning With most window managers, only a top-level windows can be in
 * full-screen mode. Hence, this function will not operate properly if
 * libvlc_media_player_set_xwindow() was used to embed the video in a
 * non-top-level window. In that case, the embedding window must be reparented
 * to the root window <b>before</b> fullscreen mode is enabled. You will want
 * to reparent it back to its normal parent when disabling fullscreen.
 *
 * \param p_mi the media player
 * \param b_fullscreen boolean for fullscreen status
 */
HB_FUNC( MYVLC_SET_FULLSCREEN )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_set_fullscreen( hMediaPlayer, (int) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_get_fullscreen( libvlc_media_player_t *p_mi );
 * Get current fullscreen status.
 *
 * \param p_mi the media player
 * \return the fullscreen status (boolean)
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_GET_FULLSCREEN )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_get_fullscreen( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API
 * void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on );
 * Enable or disable key press events handling, according to the LibVLC hotkeys
 * configuration. By default and for historical reasons, keyboard events are
 * handled by the LibVLC video widget.
 *
 * \note On X11, there can be only one subscriber for key press and mouse
 * click events per window. If your application has subscribed to those events
 * for the X window ID of the video widget, then LibVLC will not be able to
 * handle key presses and mouse clicks in any case.
 *
 * \warning This function is only implemented for X11 and Win32 at the moment.
 *
 * \param p_mi the media player
 * \param on true to handle key press events, false to ignore them.
 */
HB_FUNC( MYVLC_VIDEO_SET_KEY_INPUT )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_video_set_key_input( hMediaPlayer, (unsigned) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API
 * void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on );
 * Enable or disable mouse click events handling. By default, those events are
 * handled. This is needed for DVD menus to work, as well as a few video
 * filters such as "puzzle".
 *
 * \see libvlc_video_set_key_input().
 *
 * \warning This function is only implemented for X11 and Win32 at the moment.
 *
 * \param p_mi the media player
 * \param on true to handle mouse click events, false to ignore them.
 */
HB_FUNC( MYVLC_VIDEO_SET_MOUSE_INPUT )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_video_set_mouse_input( hMediaPlayer, (unsigned) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_audio_get_mute( libvlc_media_player_t *p_mi );
 * Get current mute status.
 *
 * \param p_mi media player
 * \return the mute status (boolean) if defined, -1 if undefined/unapplicable
 */
HB_FUNC( MYVLC_AUDIO_GET_MUTE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_audio_get_mute( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_audio_set_mute( libvlc_media_player_t *p_mi, int status );
 * Set mute status.
 *
 * \param p_mi media player
 * \param status If status is true then mute, otherwise unmute
 * \warning This function does not always work. If there are no active audio
 * playback stream, the mute status might not be available. If digital
 * pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also
 * some audio output plugins do not support muting at all.
 * \note To force silent playback, disable all audio tracks. This is more
 * efficient and reliable than mute.
 */
HB_FUNC( MYVLC_AUDIO_SET_MUTE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_audio_set_mute( hMediaPlayer, (int) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_audio_toggle_mute( libvlc_media_player_t *p_mi );
 * Toggle mute status.
 *
 * \param p_mi media player
 * \warning Toggling mute atomically is not always possible: On some platforms,
 * other processes can mute the VLC audio playback stream asynchronously. Thus,
 * there is a small race condition where toggling will not work.
 * See also the limitations of libvlc_audio_set_mute().
 */
HB_FUNC( MYVLC_AUDIO_TOGGLE_MUTE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_audio_toggle_mute( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_audio_get_volume( libvlc_media_player_t *p_mi );
 * Get current software audio volume.
 *
 * \param p_mi media player
 * \return the software volume in percents
 * (0 = mute, 100 = nominal / 0dB)
 */
HB_FUNC( MYVLC_AUDIO_GET_VOLUME )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retni( libvlc_audio_get_volume( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_audio_set_volume( libvlc_media_player_t *p_mi, int i_volume );
 * Set current software audio volume.
 *
 * \param p_mi media player
 * \param i_volume the volume in percents (0 = mute, 100 = 0dB)
 * \return 0 if the volume was set, -1 if it was out of range
 */
HB_FUNC( MYVLC_AUDIO_SET_VOLUME )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( ( libvlc_audio_set_volume( hMediaPlayer, (int) hb_parni( 2 ) )  == 0 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi );
 * Get current movie state
 *
 * \param p_mi the Media Player
 * \return the current state of the media player (playing, paused, ...) \see libvlc_state_t
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_STATE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   unsigned int uiState = 0;

   if( hMediaPlayer )
   {
      uiState = (unsigned int) libvlc_media_player_get_state( hMediaPlayer );
   }
   hb_retni( uiState );
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_release( libvlc_instance_t *p_instance );
 * Decrement the reference count of a libvlc instance, and destroy it
 * if it reaches zero.
 *
 * \param p_instance the instance to destroy
 */
HB_FUNC( MYVLC_RELEASE )
{
   libvlc_instance_t* hVLC = (libvlc_instance_t *) hb_parptr( 1 );
   if( hVLC )
   {
      libvlc_release( hVLC );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_release( libvlc_media_t *p_md );
 * Decrement the reference count of a media descriptor object. If the
 * reference count is 0, then libvlc_media_release() will release the
 * media descriptor object. It will send out an libvlc_MediaFreed event
 * to all listeners. If the media descriptor object has been released it
 * should not be used again.
 *
 * \param p_md the media descriptor
 */
HB_FUNC( MYVLC_MEDIA_RELEASE )
{
   libvlc_media_t* hMedia = (libvlc_media_t *) hb_parptr( 1 );
   if( hMedia )
   {
      libvlc_media_release( hMedia );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
* LIBVLC_API void libvlc_media_player_release (libvlc_media_player_t *p_mi)
* Release a media_player after use Decrement the reference count of a media player object.
*/
HB_FUNC( MYVLC_MEDIAPLAYER_RELEASE )
{
   libvlc_media_player_t* hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_release( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
//EOF
//------------------------------------------------------------------------------
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Mon Oct 13, 2025 05:33 AM
myvlc.c
#include <windows.h>
#include <vlc/vlc.h>
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "hbapistr.h"
#include "hbapicls.h"

//------------------------------------------------------------------------------
/**
* libvlc_instance_t * libvlc_new( int argc, const char *const * argv )
* Create and initialize a libvlc instance.
* Parameters
* argc   the number of arguments (should be 0)
* argv   list of arguments (should be NULL)
* Returns
* the libvlc instance or NULL in case of error
*/
HB_FUNC( MYVLC_NEW )
{
   libvlc_instance_t* hVlc = libvlc_new( 0, NULL );
   if( hVlc )
   {
      hb_retptr( hVlc );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_media_t *libvlc_media_new_path(
 *                                  libvlc_instance_t *p_instance,
 *                                  const char *path );
 * Create a media for a certain file path.
 *
 * \see libvlc_media_release
 *
 * \param p_instance the instance
 * \param path local filesystem path
 * \return the newly created media or NULL on error
 */
HB_FUNC( MYVLC_MEDIA_NEW )
{
   libvlc_instance_t *hVlc = (libvlc_instance_t *) hb_parptr( 1 );
   if( hVlc )
   {
      void *pstrFileName = NULL;
      hb_retptr( (void *) libvlc_media_new_path( hVlc, hb_parstr_utf8( 2, &pstrFileName, NULL ) ) );
      hb_strfree( pstrFileName );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_media_player_t * libvlc_media_player_new( libvlc_instance_t *p_libvlc_instance );
 * Create an empty Media Player object
 *
 * \param p_libvlc_instance the libvlc instance in which the Media Player
 *        should be created.
 * \return a new media player object, or NULL on error.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_NEW )
{
   libvlc_instance_t *hVlc = (libvlc_instance_t *) hb_parptr( 1 );
   if( hVlc )
   {
      libvlc_media_player_t *hMediaPlayer;
      hMediaPlayer = libvlc_media_player_new( hVlc );
      hb_retptr( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_media_player_t * libvlc_media_player_new_from_media( libvlc_media_t *p_md );
 * Create a Media Player object from a Media
 *
 * \param p_md the media. Afterwards the p_md can be safely
 *        destroyed.
 * \return a new media player object, or NULL on error.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_NEW_FROM_MEDIA )
{
   libvlc_media_t *hMedia = (libvlc_media_t *) hb_parptr( 1 );
   if( hMedia )
   {
      libvlc_media_player_t *hMediaPlayer;
      hMediaPlayer = libvlc_media_player_new_from_media( hMedia );
      hb_retptr( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_media( libvlc_media_player_t *p_mi,
 *                                                libvlc_media_t *p_md );
 * Set the media that will be used by the media_player. If any,
 * previous md will be released.
 *
 * \param p_mi the Media Player
 * \param p_md the Media. Afterwards the p_md can be safely
 *        destroyed.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_MEDIA )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   libvlc_media_t *hMedia = (libvlc_media_t *) hb_parptr( 2 );
   if( hMediaPlayer && hMedia )
   {
      libvlc_media_player_set_media( hMediaPlayer, hMedia );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_hwnd ( libvlc_media_player_t *p_mi, void *drawable );
 * Set a Win32/Win64 API window handle (HWND) where the media player should
 * render its video output. If LibVLC was built without Win32/Win64 API output
 * support, then this has no effects.
 *
 * \warning the HWND must have the WS_CLIPCHILDREN set in its style.
 *
 * \param p_mi the Media Player
 * \param drawable windows handle of the drawable
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_HWND )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   HWND hWnd = (HWND) hb_parnl( 2 );
   if( hMediaPlayer && hWnd )
   {
      libvlc_media_player_set_hwnd( hMediaPlayer, hWnd );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void *libvlc_media_player_get_hwnd ( libvlc_media_player_t *p_mi );
 * Get the Windows API window handle (HWND) previously set with
 * libvlc_media_player_set_hwnd(). The handle will be returned even if LibVLC
 * is not currently outputting any video to it.
 *
 * \param p_mi the Media Player
 * \return a window handle or NULL if there are none.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_HWND )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnl( (HB_LONG) libvlc_media_player_get_hwnd( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * Is the player able to play
 * LIBVLC_API int libvlc_media_player_will_play( libvlc_media_player_t *p_mi );
 *
 * \param p_mi the Media Player
 * \return boolean
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_WILL_PLAY )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_media_player_will_play( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_media_player_play ( libvlc_media_player_t *p_mi );
 * Play
 *
 * \param p_mi the Media Player
 * \return 0 if playback started (and was already started), or -1 on error.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_PLAY )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_media_player_play( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_media_player_is_playing ( libvlc_media_player_t *p_mi );
 * is_playing
 *
 * \param p_mi the Media Player
 * \return 1 if the media player is playing, 0 otherwise
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_ISPLAYING )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
       hb_retl( (HB_BOOL) libvlc_media_player_is_playing( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi );
 * Can this media player be paused?
 *
 * \param p_mi the media player
 * \return true if the media player can pause
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_CAN_PAUSE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_media_player_can_pause( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_pause ( libvlc_media_player_t *mp,
 *                                                 int do_pause );
 * Pause or resume (no effect if there is no media)
 *
 * \param mp the Media Player
 * \param do_pause play/resume if zero, pause if non-zero
 * \version LibVLC 1.1.1 or later
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_PAUSE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_set_pause( hMediaPlayer, (int) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_pause ( libvlc_media_player_t *p_mi );
 * Toggle pause (no effect if there is no media)
 *
 * \param p_mi the Media Player
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_PAUSE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_pause( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_stop ( libvlc_media_player_t *p_mi );
 * Stop (no effect if there is no media)
 *
 * \param p_mi the Media Player
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_STOP )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_stop( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_time_t libvlc_media_player_get_length( libvlc_media_player_t *p_mi );
 * Get the current movie length (in ms).
 *
 * \param p_mi the Media Player
 * \return the movie length (in ms), or -1 if there is no media.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_LENGTH )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnl( (HB_ULONG) libvlc_media_player_get_length( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t *p_mi );
 * Get the current movie time (in ms).
 *
 * \param p_mi the Media Player
 * \return the movie time (in ms), or -1 if there is no media.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_TIME )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnl( (HB_ULONG) libvlc_media_player_get_time( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API float libvlc_media_player_get_position( libvlc_media_player_t *p_mi );
 * Get movie position as percentage between 0.0 and 1.0.
 *
 * \param p_mi the Media Player
 * \return movie position, or -1. in case of error
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_POSITION )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnd( (double) libvlc_media_player_get_position( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_position( libvlc_media_player_t *p_mi, float f_pos );
 * Set movie position as percentage between 0.0 and 1.0.
 * This has no effect if playback is not enabled.
 * This might not work depending on the underlying input format and protocol.
 *
 * \param p_mi the Media Player
 * \param f_pos the position
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_POSITION )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_set_position( hMediaPlayer, (float) hb_parnd( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_set_fullscreen( libvlc_media_player_t *p_mi, int b_fullscreen );
 * Enable or disable fullscreen.
 *
 * @warning With most window managers, only a top-level windows can be in
 * full-screen mode. Hence, this function will not operate properly if
 * libvlc_media_player_set_xwindow() was used to embed the video in a
 * non-top-level window. In that case, the embedding window must be reparented
 * to the root window <b>before</b> fullscreen mode is enabled. You will want
 * to reparent it back to its normal parent when disabling fullscreen.
 *
 * \param p_mi the media player
 * \param b_fullscreen boolean for fullscreen status
 */
HB_FUNC( MYVLC_SET_FULLSCREEN )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_set_fullscreen( hMediaPlayer, (int) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_get_fullscreen( libvlc_media_player_t *p_mi );
 * Get current fullscreen status.
 *
 * \param p_mi the media player
 * \return the fullscreen status (boolean)
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_GET_FULLSCREEN )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_get_fullscreen( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API
 * void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on );
 * Enable or disable key press events handling, according to the LibVLC hotkeys
 * configuration. By default and for historical reasons, keyboard events are
 * handled by the LibVLC video widget.
 *
 * \note On X11, there can be only one subscriber for key press and mouse
 * click events per window. If your application has subscribed to those events
 * for the X window ID of the video widget, then LibVLC will not be able to
 * handle key presses and mouse clicks in any case.
 *
 * \warning This function is only implemented for X11 and Win32 at the moment.
 *
 * \param p_mi the media player
 * \param on true to handle key press events, false to ignore them.
 */
HB_FUNC( MYVLC_VIDEO_SET_KEY_INPUT )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_video_set_key_input( hMediaPlayer, (unsigned) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API
 * void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on );
 * Enable or disable mouse click events handling. By default, those events are
 * handled. This is needed for DVD menus to work, as well as a few video
 * filters such as "puzzle".
 *
 * \see libvlc_video_set_key_input().
 *
 * \warning This function is only implemented for X11 and Win32 at the moment.
 *
 * \param p_mi the media player
 * \param on true to handle mouse click events, false to ignore them.
 */
HB_FUNC( MYVLC_VIDEO_SET_MOUSE_INPUT )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_video_set_mouse_input( hMediaPlayer, (unsigned) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_audio_get_mute( libvlc_media_player_t *p_mi );
 * Get current mute status.
 *
 * \param p_mi media player
 * \return the mute status (boolean) if defined, -1 if undefined/unapplicable
 */
HB_FUNC( MYVLC_AUDIO_GET_MUTE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_audio_get_mute( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_audio_set_mute( libvlc_media_player_t *p_mi, int status );
 * Set mute status.
 *
 * \param p_mi media player
 * \param status If status is true then mute, otherwise unmute
 * \warning This function does not always work. If there are no active audio
 * playback stream, the mute status might not be available. If digital
 * pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also
 * some audio output plugins do not support muting at all.
 * \note To force silent playback, disable all audio tracks. This is more
 * efficient and reliable than mute.
 */
HB_FUNC( MYVLC_AUDIO_SET_MUTE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_audio_set_mute( hMediaPlayer, (int) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_audio_toggle_mute( libvlc_media_player_t *p_mi );
 * Toggle mute status.
 *
 * \param p_mi media player
 * \warning Toggling mute atomically is not always possible: On some platforms,
 * other processes can mute the VLC audio playback stream asynchronously. Thus,
 * there is a small race condition where toggling will not work.
 * See also the limitations of libvlc_audio_set_mute().
 */
HB_FUNC( MYVLC_AUDIO_TOGGLE_MUTE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_audio_toggle_mute( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_audio_get_volume( libvlc_media_player_t *p_mi );
 * Get current software audio volume.
 *
 * \param p_mi media player
 * \return the software volume in percents
 * (0 = mute, 100 = nominal / 0dB)
 */
HB_FUNC( MYVLC_AUDIO_GET_VOLUME )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retni( libvlc_audio_get_volume( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_audio_set_volume( libvlc_media_player_t *p_mi, int i_volume );
 * Set current software audio volume.
 *
 * \param p_mi media player
 * \param i_volume the volume in percents (0 = mute, 100 = 0dB)
 * \return 0 if the volume was set, -1 if it was out of range
 */
HB_FUNC( MYVLC_AUDIO_SET_VOLUME )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( ( libvlc_audio_set_volume( hMediaPlayer, (int) hb_parni( 2 ) )  == 0 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi );
 * Get current movie state
 *
 * \param p_mi the Media Player
 * \return the current state of the media player (playing, paused, ...) \see libvlc_state_t
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_STATE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   unsigned int uiState = 0;

   if( hMediaPlayer )
   {
      uiState = (unsigned int) libvlc_media_player_get_state( hMediaPlayer );
   }
   hb_retni( uiState );
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_release( libvlc_instance_t *p_instance );
 * Decrement the reference count of a libvlc instance, and destroy it
 * if it reaches zero.
 *
 * \param p_instance the instance to destroy
 */
HB_FUNC( MYVLC_RELEASE )
{
   libvlc_instance_t* hVLC = (libvlc_instance_t *) hb_parptr( 1 );
   if( hVLC )
   {
      libvlc_release( hVLC );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_release( libvlc_media_t *p_md );
 * Decrement the reference count of a media descriptor object. If the
 * reference count is 0, then libvlc_media_release() will release the
 * media descriptor object. It will send out an libvlc_MediaFreed event
 * to all listeners. If the media descriptor object has been released it
 * should not be used again.
 *
 * \param p_md the media descriptor
 */
HB_FUNC( MYVLC_MEDIA_RELEASE )
{
   libvlc_media_t* hMedia = (libvlc_media_t *) hb_parptr( 1 );
   if( hMedia )
   {
      libvlc_media_release( hMedia );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
* LIBVLC_API void libvlc_media_player_release (libvlc_media_player_t *p_mi)
* Release a media_player after use Decrement the reference count of a media player object.
*/
HB_FUNC( MYVLC_MEDIAPLAYER_RELEASE )
{
   libvlc_media_player_t* hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_release( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
//EOF
//------------------------------------------------------------------------------
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Mon Oct 13, 2025 05:33 AM
myvlc.c
#include <windows.h>
#include <vlc/vlc.h>
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "hbapistr.h"
#include "hbapicls.h"

//------------------------------------------------------------------------------
/**
* libvlc_instance_t * libvlc_new( int argc, const char *const * argv )
* Create and initialize a libvlc instance.
* Parameters
* argc   the number of arguments (should be 0)
* argv   list of arguments (should be NULL)
* Returns
* the libvlc instance or NULL in case of error
*/
HB_FUNC( MYVLC_NEW )
{
   libvlc_instance_t* hVlc = libvlc_new( 0, NULL );
   if( hVlc )
   {
      hb_retptr( hVlc );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_media_t *libvlc_media_new_path(
 *                                  libvlc_instance_t *p_instance,
 *                                  const char *path );
 * Create a media for a certain file path.
 *
 * \see libvlc_media_release
 *
 * \param p_instance the instance
 * \param path local filesystem path
 * \return the newly created media or NULL on error
 */
HB_FUNC( MYVLC_MEDIA_NEW )
{
   libvlc_instance_t *hVlc = (libvlc_instance_t *) hb_parptr( 1 );
   if( hVlc )
   {
      void *pstrFileName = NULL;
      hb_retptr( (void *) libvlc_media_new_path( hVlc, hb_parstr_utf8( 2, &pstrFileName, NULL ) ) );
      hb_strfree( pstrFileName );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_media_player_t * libvlc_media_player_new( libvlc_instance_t *p_libvlc_instance );
 * Create an empty Media Player object
 *
 * \param p_libvlc_instance the libvlc instance in which the Media Player
 *        should be created.
 * \return a new media player object, or NULL on error.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_NEW )
{
   libvlc_instance_t *hVlc = (libvlc_instance_t *) hb_parptr( 1 );
   if( hVlc )
   {
      libvlc_media_player_t *hMediaPlayer;
      hMediaPlayer = libvlc_media_player_new( hVlc );
      hb_retptr( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_media_player_t * libvlc_media_player_new_from_media( libvlc_media_t *p_md );
 * Create a Media Player object from a Media
 *
 * \param p_md the media. Afterwards the p_md can be safely
 *        destroyed.
 * \return a new media player object, or NULL on error.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_NEW_FROM_MEDIA )
{
   libvlc_media_t *hMedia = (libvlc_media_t *) hb_parptr( 1 );
   if( hMedia )
   {
      libvlc_media_player_t *hMediaPlayer;
      hMediaPlayer = libvlc_media_player_new_from_media( hMedia );
      hb_retptr( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_media( libvlc_media_player_t *p_mi,
 *                                                libvlc_media_t *p_md );
 * Set the media that will be used by the media_player. If any,
 * previous md will be released.
 *
 * \param p_mi the Media Player
 * \param p_md the Media. Afterwards the p_md can be safely
 *        destroyed.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_MEDIA )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   libvlc_media_t *hMedia = (libvlc_media_t *) hb_parptr( 2 );
   if( hMediaPlayer && hMedia )
   {
      libvlc_media_player_set_media( hMediaPlayer, hMedia );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_hwnd ( libvlc_media_player_t *p_mi, void *drawable );
 * Set a Win32/Win64 API window handle (HWND) where the media player should
 * render its video output. If LibVLC was built without Win32/Win64 API output
 * support, then this has no effects.
 *
 * \warning the HWND must have the WS_CLIPCHILDREN set in its style.
 *
 * \param p_mi the Media Player
 * \param drawable windows handle of the drawable
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_HWND )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   HWND hWnd = (HWND) hb_parnl( 2 );
   if( hMediaPlayer && hWnd )
   {
      libvlc_media_player_set_hwnd( hMediaPlayer, hWnd );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void *libvlc_media_player_get_hwnd ( libvlc_media_player_t *p_mi );
 * Get the Windows API window handle (HWND) previously set with
 * libvlc_media_player_set_hwnd(). The handle will be returned even if LibVLC
 * is not currently outputting any video to it.
 *
 * \param p_mi the Media Player
 * \return a window handle or NULL if there are none.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_HWND )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnl( (HB_LONG) libvlc_media_player_get_hwnd( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * Is the player able to play
 * LIBVLC_API int libvlc_media_player_will_play( libvlc_media_player_t *p_mi );
 *
 * \param p_mi the Media Player
 * \return boolean
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_WILL_PLAY )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_media_player_will_play( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_media_player_play ( libvlc_media_player_t *p_mi );
 * Play
 *
 * \param p_mi the Media Player
 * \return 0 if playback started (and was already started), or -1 on error.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_PLAY )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_media_player_play( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_media_player_is_playing ( libvlc_media_player_t *p_mi );
 * is_playing
 *
 * \param p_mi the Media Player
 * \return 1 if the media player is playing, 0 otherwise
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_ISPLAYING )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
       hb_retl( (HB_BOOL) libvlc_media_player_is_playing( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi );
 * Can this media player be paused?
 *
 * \param p_mi the media player
 * \return true if the media player can pause
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_CAN_PAUSE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_media_player_can_pause( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_pause ( libvlc_media_player_t *mp,
 *                                                 int do_pause );
 * Pause or resume (no effect if there is no media)
 *
 * \param mp the Media Player
 * \param do_pause play/resume if zero, pause if non-zero
 * \version LibVLC 1.1.1 or later
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_PAUSE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_set_pause( hMediaPlayer, (int) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_pause ( libvlc_media_player_t *p_mi );
 * Toggle pause (no effect if there is no media)
 *
 * \param p_mi the Media Player
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_PAUSE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_pause( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_stop ( libvlc_media_player_t *p_mi );
 * Stop (no effect if there is no media)
 *
 * \param p_mi the Media Player
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_STOP )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_stop( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_time_t libvlc_media_player_get_length( libvlc_media_player_t *p_mi );
 * Get the current movie length (in ms).
 *
 * \param p_mi the Media Player
 * \return the movie length (in ms), or -1 if there is no media.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_LENGTH )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnl( (HB_ULONG) libvlc_media_player_get_length( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t *p_mi );
 * Get the current movie time (in ms).
 *
 * \param p_mi the Media Player
 * \return the movie time (in ms), or -1 if there is no media.
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_TIME )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnl( (HB_ULONG) libvlc_media_player_get_time( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API float libvlc_media_player_get_position( libvlc_media_player_t *p_mi );
 * Get movie position as percentage between 0.0 and 1.0.
 *
 * \param p_mi the Media Player
 * \return movie position, or -1. in case of error
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_POSITION )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retnd( (double) libvlc_media_player_get_position( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_player_set_position( libvlc_media_player_t *p_mi, float f_pos );
 * Set movie position as percentage between 0.0 and 1.0.
 * This has no effect if playback is not enabled.
 * This might not work depending on the underlying input format and protocol.
 *
 * \param p_mi the Media Player
 * \param f_pos the position
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_SET_POSITION )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_set_position( hMediaPlayer, (float) hb_parnd( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_set_fullscreen( libvlc_media_player_t *p_mi, int b_fullscreen );
 * Enable or disable fullscreen.
 *
 * @warning With most window managers, only a top-level windows can be in
 * full-screen mode. Hence, this function will not operate properly if
 * libvlc_media_player_set_xwindow() was used to embed the video in a
 * non-top-level window. In that case, the embedding window must be reparented
 * to the root window <b>before</b> fullscreen mode is enabled. You will want
 * to reparent it back to its normal parent when disabling fullscreen.
 *
 * \param p_mi the media player
 * \param b_fullscreen boolean for fullscreen status
 */
HB_FUNC( MYVLC_SET_FULLSCREEN )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_set_fullscreen( hMediaPlayer, (int) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_get_fullscreen( libvlc_media_player_t *p_mi );
 * Get current fullscreen status.
 *
 * \param p_mi the media player
 * \return the fullscreen status (boolean)
 *
 * \libvlc_return_bool
 */
HB_FUNC( MYVLC_GET_FULLSCREEN )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_get_fullscreen( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API
 * void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on );
 * Enable or disable key press events handling, according to the LibVLC hotkeys
 * configuration. By default and for historical reasons, keyboard events are
 * handled by the LibVLC video widget.
 *
 * \note On X11, there can be only one subscriber for key press and mouse
 * click events per window. If your application has subscribed to those events
 * for the X window ID of the video widget, then LibVLC will not be able to
 * handle key presses and mouse clicks in any case.
 *
 * \warning This function is only implemented for X11 and Win32 at the moment.
 *
 * \param p_mi the media player
 * \param on true to handle key press events, false to ignore them.
 */
HB_FUNC( MYVLC_VIDEO_SET_KEY_INPUT )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_video_set_key_input( hMediaPlayer, (unsigned) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API
 * void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on );
 * Enable or disable mouse click events handling. By default, those events are
 * handled. This is needed for DVD menus to work, as well as a few video
 * filters such as "puzzle".
 *
 * \see libvlc_video_set_key_input().
 *
 * \warning This function is only implemented for X11 and Win32 at the moment.
 *
 * \param p_mi the media player
 * \param on true to handle mouse click events, false to ignore them.
 */
HB_FUNC( MYVLC_VIDEO_SET_MOUSE_INPUT )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_video_set_mouse_input( hMediaPlayer, (unsigned) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_audio_get_mute( libvlc_media_player_t *p_mi );
 * Get current mute status.
 *
 * \param p_mi media player
 * \return the mute status (boolean) if defined, -1 if undefined/unapplicable
 */
HB_FUNC( MYVLC_AUDIO_GET_MUTE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( (HB_BOOL) libvlc_audio_get_mute( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_audio_set_mute( libvlc_media_player_t *p_mi, int status );
 * Set mute status.
 *
 * \param p_mi media player
 * \param status If status is true then mute, otherwise unmute
 * \warning This function does not always work. If there are no active audio
 * playback stream, the mute status might not be available. If digital
 * pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also
 * some audio output plugins do not support muting at all.
 * \note To force silent playback, disable all audio tracks. This is more
 * efficient and reliable than mute.
 */
HB_FUNC( MYVLC_AUDIO_SET_MUTE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_audio_set_mute( hMediaPlayer, (int) hb_parl( 2 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_audio_toggle_mute( libvlc_media_player_t *p_mi );
 * Toggle mute status.
 *
 * \param p_mi media player
 * \warning Toggling mute atomically is not always possible: On some platforms,
 * other processes can mute the VLC audio playback stream asynchronously. Thus,
 * there is a small race condition where toggling will not work.
 * See also the limitations of libvlc_audio_set_mute().
 */
HB_FUNC( MYVLC_AUDIO_TOGGLE_MUTE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_audio_toggle_mute( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_audio_get_volume( libvlc_media_player_t *p_mi );
 * Get current software audio volume.
 *
 * \param p_mi media player
 * \return the software volume in percents
 * (0 = mute, 100 = nominal / 0dB)
 */
HB_FUNC( MYVLC_AUDIO_GET_VOLUME )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retni( libvlc_audio_get_volume( hMediaPlayer ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API int libvlc_audio_set_volume( libvlc_media_player_t *p_mi, int i_volume );
 * Set current software audio volume.
 *
 * \param p_mi media player
 * \param i_volume the volume in percents (0 = mute, 100 = 0dB)
 * \return 0 if the volume was set, -1 if it was out of range
 */
HB_FUNC( MYVLC_AUDIO_SET_VOLUME )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      hb_retl( ( libvlc_audio_set_volume( hMediaPlayer, (int) hb_parni( 2 ) )  == 0 ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi );
 * Get current movie state
 *
 * \param p_mi the Media Player
 * \return the current state of the media player (playing, paused, ...) \see libvlc_state_t
 */
HB_FUNC( MYVLC_MEDIA_PLAYER_GET_STATE )
{
   libvlc_media_player_t *hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   unsigned int uiState = 0;

   if( hMediaPlayer )
   {
      uiState = (unsigned int) libvlc_media_player_get_state( hMediaPlayer );
   }
   hb_retni( uiState );
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_release( libvlc_instance_t *p_instance );
 * Decrement the reference count of a libvlc instance, and destroy it
 * if it reaches zero.
 *
 * \param p_instance the instance to destroy
 */
HB_FUNC( MYVLC_RELEASE )
{
   libvlc_instance_t* hVLC = (libvlc_instance_t *) hb_parptr( 1 );
   if( hVLC )
   {
      libvlc_release( hVLC );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
 * LIBVLC_API void libvlc_media_release( libvlc_media_t *p_md );
 * Decrement the reference count of a media descriptor object. If the
 * reference count is 0, then libvlc_media_release() will release the
 * media descriptor object. It will send out an libvlc_MediaFreed event
 * to all listeners. If the media descriptor object has been released it
 * should not be used again.
 *
 * \param p_md the media descriptor
 */
HB_FUNC( MYVLC_MEDIA_RELEASE )
{
   libvlc_media_t* hMedia = (libvlc_media_t *) hb_parptr( 1 );
   if( hMedia )
   {
      libvlc_media_release( hMedia );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
/**
* LIBVLC_API void libvlc_media_player_release (libvlc_media_player_t *p_mi)
* Release a media_player after use Decrement the reference count of a media player object.
*/
HB_FUNC( MYVLC_MEDIAPLAYER_RELEASE )
{
   libvlc_media_player_t* hMediaPlayer = (libvlc_media_player_t *) hb_parptr( 1 );
   if( hMediaPlayer )
   {
      libvlc_media_player_release( hMediaPlayer );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}

//------------------------------------------------------------------------------
//EOF
//------------------------------------------------------------------------------
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Mon Oct 13, 2025 05:34 AM
tvlcplayer.prg
#include "fivewin.ch"
#include "common.ch"

#define VLC_VOLUME_STEP    5

//------------------------------------------------------------------------------

CLASS TVlcPlayer
   DATA hWnd
   DATA hVlc
   DATA hMediaPlayer
   DATA hMedia
   DATA nVolume

   METHOD New( hWnd ) CONSTRUCTOR
   METHOD SetWindow( hWnd )
   METHOD GetState()
   METHOD SetVolume( nVolume )
   METHOD GetVolume()
   METHOD GetVolumeStr() INLINE StrZero( ::GetVolume, 2 )
   METHOD VolumeUp()
   METHOD VolumeDown()
   METHOD SetMediaFile( cFile )
   METHOD IsPlayable()
   METHOD Play()
   METHOD IsPlaying()
   METHOD CanPause()
   METHOD Pause()
   METHOD Stop()
   METHOD GetLength()
   METHOD GetLengthStr() INLINE MillisecondsToTime( ::GetLength() )
   METHOD GetTime()
   METHOD GetTimeStr() INLINE MillisecondsToTime( ::GetTime() )
   METHOD GetPosition()
   METHOD IsFullScreen()
   METHOD FullScreen()
   METHOD End()
ENDCLASS

//------------------------------------------------------------------------------

METHOD New( hWnd ) CLASS TVlcPlayer
   ::hWnd := hWnd
   ::hVlc := myvlc_new()
   IF !Empty( ::hVlc )
      ::hMediaPlayer := myvlc_media_player_new( ::hVlc )
      IF !Empty( ::hWnd ) .and. !Empty( ::hMediaPlayer )
         myvlc_video_set_key_input( ::hMediaPlayer, FALSE )
         myvlc_video_set_mouse_input( ::hMediaPlayer, FALSE )
         ::SetWindow( ::hWnd )
         ::SetVolume( 50 )
      ENDIF
   ENDIF
RETURN Self

//------------------------------------------------------------------------------

METHOD SetWindow( hWnd ) CLASS TVlcPlayer
   IF !Empty( hWnd ) .and. !Empty( ::hMediaPlayer )
      myvlc_media_player_set_hwnd( ::hMediaPlayer, hWnd )
   ENDIF
RETURN NIL

//------------------------------------------------------------------------------

METHOD GetState() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      RETURN myvlc_media_player_get_state( ::hMediaPlayer )
   ENDIF
RETURN MYVLC_NOTHINGSPECIAL

//------------------------------------------------------------------------------

METHOD SetVolume( nVolume ) CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      IF IsBetween( nVolume, 0, 100 )
         IF myvlc_audio_set_volume( ::hMediaPlayer, nVolume )
            ::nVolume := ::GetVolume()
         ENDIF
      ENDIF
   ENDIF
RETURN FALSE

//------------------------------------------------------------------------------

METHOD GetVolume() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      ::nVolume := myvlc_audio_get_volume( ::hMediaPlayer )
   ENDIF
RETURN ::nVolume

//------------------------------------------------------------------------------

METHOD VolumeUp() CLASS TVlcPlayer
   LOCAL nVolumeNew
   IF ::nVolume < 100
      nVolumeNew := ::nVolume + VLC_VOLUME_STEP
      IF ::nVolumeNew > 100
         ::nVolumeNew := 100
      ENDIF
      ::SetVolume( nVolumeNew )
      ::nVolume := ::GetVolume()
   ENDIF
RETURN ::nVolume

//------------------------------------------------------------------------------

METHOD VolumeDown() CLASS TVlcPlayer
   LOCAL nVolumeNew
   IF ::nVolume > 0
      nVolumeNew := ::nVolume - VLC_VOLUME_STEP
      IF ::nVolumeNew < 0
         ::nVolumeNew := 0
      ENDIF
      ::SetVolume( nVolumeNew )
      ::nVolume := ::GetVolume()
   ENDIF
RETURN

//------------------------------------------------------------------------------

METHOD SetMediaFile( cFile ) CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer ) .and. !Empty( ::hWnd )
      ::hMedia := myvlc_media_new( ::hVlc, cFile )
      IF !Empty( ::hMedia )
         myvlc_media_player_set_media( ::hMediaPlayer, ::hMedia )
         myvlc_media_release( ::hMedia )
         ::hMedia := NIL
      ENDIF
   ENDIF
RETURN NIL

//------------------------------------------------------------------------------

METHOD IsPlayable() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer ) .and. !myvlc_media_player_isplaying( ::hMediaPlayer )
      RETURN myvlc_media_player_will_play( ::hMediaPlayer )
   ENDIF
RETURN FALSE

//------------------------------------------------------------------------------

METHOD Play() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer ) .and. !myvlc_media_player_isplaying( ::hMediaPlayer )
      RETURN myvlc_media_player_play( ::hMediaPlayer )
   ENDIF
RETURN FALSE

//------------------------------------------------------------------------------

METHOD IsPlaying() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      RETURN myvlc_media_player_isplaying( ::hMediaPlayer )
   ENDIF
RETURN FALSE

//------------------------------------------------------------------------------

METHOD CanPause() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      RETURN myvlc_media_player_can_pause( ::hMediaPlayer )
   ENDIF
RETURN FALSE

//------------------------------------------------------------------------------

METHOD Pause() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      myvlc_media_player_pause( ::hMediaPlayer )
   ENDIF
RETURN NIL

//------------------------------------------------------------------------------

METHOD Stop() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      myvlc_media_player_stop( ::hMediaPlayer )
   ENDIF
RETURN NIL

//------------------------------------------------------------------------------

METHOD GetTime() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      RETURN myvlc_media_player_get_time( ::hMediaPlayer )
   ENDIF
RETURN 0

//------------------------------------------------------------------------------

METHOD GetLength() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      RETURN myvlc_media_player_get_length( ::hMediaPlayer )
   ENDIF
RETURN 0

//------------------------------------------------------------------------------

METHOD GetPosition() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      RETURN myvlc_media_player_get_position( ::hMediaPlayer )
   ENDIF
RETURN 0

//------------------------------------------------------------------------------

METHOD IsFullScreen() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      RETURN myvlc_get_fullscreen( ::hMediaPlayer )
   ENDIF
RETURN FALSE
//------------------------------------------------------------------------------

METHOD FullScreen() CLASS TVlcPlayer
   IF !Empty( ::hMediaPlayer )
      myvlc_set_fullscreen( ::hMediaPlayer, !lFullScreen )
   ENDIF
RETURN NIL

//------------------------------------------------------------------------------

METHOD End() CLASS TVlcPlayer
   ::Stop()
   IF !Empty( ::hMediaPlayer  )
      myvlc_mediaplayer_release( ::hMediaPlayer )
      ::hMediaPlayer := NIL
   ENDIF
   IF !Empty( ::hVlc )
      myvlc_release( ::hVlc )
      ::hVlc := NIL
   ENDIF
RETURN NIL

//------------------------------------------------------------------------------

STATIC FUNCTION MillisecondsToTime( nMilliseconds )
    LOCAL nHours, nMinutes, nSeconds
    LOCAL cTime

    // Calculate hours, minutes, seconds, and milliseconds
    nHours    := Int( nMilliseconds / 3600000 )
    nMinutes  := Int( ( nMilliseconds % 3600000 ) / 60000 )
    nSeconds  := Int( ( nMilliseconds % 60000 ) / 1000 )

    // Format the time as a string
    cTime := StrZero( nHours  , 2 ) + ":" + ;
             StrZero( nMinutes, 2 ) + ":" + ;
             StrZero( nSeconds, 2 )

RETURN cTime

//------------------------------------------------------------------------------

STATIC FUNCTION IsBetween( uValue, u1, u2 )
   LOCAL lBetween := FALSE
   IF u2 >= u1
      lBetween := ( uValue >= u1 .and. uValue <= u2 )
   ELSE
      lBetween := ( uValue >= u2 .and. uValue <= u1 )
   ENDIF
RETURN lBetween

//------------------------------------------------------------------------------
//EOF
//------------------------------------------------------------------------------
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Mon Oct 13, 2025 05:35 AM

de las dll extraje la lib.

usando implib en el caso del compilador bcc, para otros compiladores es un proceso similar, crear el def file, modificarlo si es necesario y credo la lib a partir del def.

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 34
Joined: Tue Mar 20, 2012 11:06 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Mon Oct 13, 2025 10:40 PM
carlos vargas wrote: de las dll extraje la lib.
usando implib en el caso del compilador bcc, para otros compiladores es un proceso similar, crear el def file, modificarlo si es necesario y credo la lib a partir del def.
buenisimo Cesar: en mi caso hice una wrapper de Libvlc.dll ya consegui el puntero de vlcINIT() ahora estoy trabajando con VlcPlay() y colocarlo en un FRAME , cuando este implementado y funcional voy a crear Threat para poder ver camaras simultaneas... un poco tedioso porque hace años no trabajo con programacion y es un reto tipo hobby. te agradesco la ayuda porque voy a estudiar el .c

WrapperVLC.c
// ---------------------------------------------------------------------------
// vlcwrapper.cpp - modificar para exponer API simple (global context)
// ---------------------------------------------------------------------------

#include <vlc/vlc.h>
#include <iostream>

#ifdef _WIN32
  #define DLL_EXPORT extern "C" __declspec(dllexport)
#else
  #define DLL_EXPORT extern "C"
#endif

struct VLCContext {
    libvlc_instance_t* instance = nullptr;
    libvlc_media_player_t* player = nullptr;
};

static VLCContext * g_ctx = nullptr;

// Inicializa VLC y guarda contexto en g_ctx
DLL_EXPORT int vlc_init()
{
    if( g_ctx ) return 1; // ya inicializado

    const char* args[] = { "--quiet", "--no-xlib" };
    g_ctx = new VLCContext();
    g_ctx->instance = libvlc_new( sizeof(args)/sizeof(args[0]), args );
    if( ! g_ctx->instance ) {
        delete g_ctx; g_ctx = nullptr;
        return 0;
    }
    g_ctx->player = libvlc_media_player_new(g_ctx->instance);
    if( ! g_ctx->player ) {
        libvlc_release(g_ctx->instance);
        delete g_ctx; g_ctx = nullptr;
        return 0;
    }
    return 1;
}

// Reproduce usando el contexto global. path = ruta o URL
DLL_EXPORT int vlc_play_path(const char * path)
{
    if( ! g_ctx || ! g_ctx->instance || ! g_ctx->player || ! path )
        return 0;

    libvlc_media_t *media = libvlc_media_new_path(g_ctx->instance, path);
    if( ! media ) return 0;

    libvlc_media_player_set_media(g_ctx->player, media);
    libvlc_media_player_play(g_ctx->player);
    libvlc_media_release(media);
    return 1;
}

// Detener
DLL_EXPORT void vlc_stop()
{
    if( g_ctx && g_ctx->player ) {
        libvlc_media_player_stop(g_ctx->player);
    }
}

// Cerrar y liberar contexto global
DLL_EXPORT void vlc_close()
{
    if( ! g_ctx ) return;
    if( g_ctx->player ) {
        libvlc_media_player_release(g_ctx->player);
        g_ctx->player = nullptr;
    }
    if( g_ctx->instance ) {
        libvlc_release(g_ctx->instance);
        g_ctx->instance = nullptr;
    }
    delete g_ctx;
    g_ctx = nullptr;
}
Posts: 34
Joined: Tue Mar 20, 2012 11:06 PM
Re: clase VLC para crear un player - algunos problemas
Posted: Mon Nov 10, 2025 10:06 PM

Gracias Cesar un VEZ mas. Ya termine mi clase tVlc con el bridge_vlc que implemente y es funcional,, en HMG esta dentro de un Frame del GUI , pero se me ocurrio probar en cmd y dos semanas me tomo implementarlo como ejemplo.

dejo enlace Drive para que puedan probarlo y usarlo : https://drive.google.com/drive/folders/1UfYb9kGHRknOB1NRbPoX0euyg7amIuJF?usp=sharing
hay detalles a mejorar, desde ya un gusto leerlos

Continue the discussion