Code: Select all
...
// create vlc instance
m_iVlcInstance = VLC_Create();
// init vlc
char *ppsz_argv[2] = { "C:\\Programme\\VideoLAN\\VLC", "--no-one-instance" };
VLC_Init(m_iVlcInstance, 2, ppsz_argv);
...
/* set internal video width and height */
vlc_value_t val;
val.i_int = rcClient.right - rcClient.left;
int iResult = VariableSet(m_iVlcInstance, "conf::width", val);
val.i_int = rcClient.bottom-rcClient.top;
iResult = VLC_VariableSet(m_iVlcInstance, "conf::height", val);
/* set internal video parent window */
/* horrible cast there */
val.i_int = reinterpret_cast<int>(m_hWnd); // -> thisis my window handle!!!
iResult = VLC_VariableSet(m_iVlcInstance, "drawable", val);
// add video stream
iResult = VLC_AddTarget(m_iVlcInstance, "D:\\videostream.mpeg", NULL, 0, PLAYLIST_APPEND , PLAYLIST_END);
// play
iResult = VLC_Play(m_iVlcInstance);
Code: Select all
unit vlc;
interface
type
vlc_bool_t=integer;
vlc_int64_t=int64;
//typedef struct vlc_list_t vlc_list_t;
//typedef struct vlc_object_t vlc_object_t;
const
VLC_VAR_VOID =$0010;
VLC_VAR_BOOL =$0020;
VLC_VAR_INTEGER =$0030;
VLC_VAR_HOTKEY =$0031;
VLC_VAR_STRING =$0040;
VLC_VAR_MODULE =$0041;
VLC_VAR_FILE =$0042;
VLC_VAR_DIRECTORY=$0043;
VLC_VAR_VARIABLE =$0044;
VLC_VAR_FLOAT =$0050;
VLC_VAR_TIME =$0060;
VLC_VAR_ADDRESS =$0070;
VLC_VAR_MUTEX =$0080;
VLC_VAR_LIST =$0090;
type
vlc_value_t=packed record
a, b, c, d, e, f, g, h:char;
end;
//typedef union
//{
// int i_int;
// vlc_bool_t b_bool;
// float f_float;
// char * psz_string;
// void * p_address;
// vlc_object_t * p_object;
// vlc_list_t * p_list;
// vlc_int64_t i_time;
//
// struct { char *psz_name; int i_object_id; } var;
//
// /* Make sure the structure is at least 64bits */
// struct { char a, b, c, d, e, f, g, h; } padding;
//} ;
function vlc_int(const val:vlc_value_t):integer;overload;
function vlc_int(val:integer):vlc_value_t;overload;
function vlc_bool(const val:vlc_value_t):vlc_bool_t;overload;
function vlc_bool(val:vlc_bool_t):vlc_value_t;overload;
function vlc_pchar(const val:vlc_value_t):Pchar;overload;
function vlc_pchar(val:Pchar):vlc_value_t;overload;
function vlc_time(const val:vlc_value_t):vlc_int64_t;overload;
function vlc_time(val:vlc_int64_t):vlc_value_t;overload;
//struct vlc_list_t
//{
// int i_count;
// vlc_value_t * p_values;
// int * pi_types;
//};
//*****************************************************************************
// * Error values
// *****************************************************************************/
const
VLC_SUCCESS =-0;// /* No error */
VLC_ENOMEM =-1;// /* Not enough memory */
VLC_ETHREAD =-2;// /* Thread error */
VLC_ETIMEOUT =-3;// /* Timeout */
VLC_ENOMOD =-10;// /* Module not found */
VLC_ENOOBJ =-20;// /* Object not found */
VLC_EBADOBJ =-21;// /* Bad object type */
VLC_ENOVAR =-30;// /* Variable not found */
VLC_EBADVAR =-31;// /* Bad variable value */
VLC_EEXIT =-255;// /* Program exited */
VLC_EEXITSUCCESS =-999;// /* Program exited successfully */
VLC_EGENERIC =-666;// /* Generic error */
//*****************************************************************************
// * Booleans
//*****************************************************************************/
VLC_FALSE =0;
VLC_TRUE =1;
///*****************************************************************************
// * Playlist
// *****************************************************************************/
///* Used by VLC_AddTarget() */
PLAYLIST_INSERT =$0001;
PLAYLIST_REPLACE =$0002;
PLAYLIST_APPEND =$0004;
PLAYLIST_GO =$0008;
PLAYLIST_CHECK_INSERT =$0010;
PLAYLIST_PREPARSE =$0020;
PLAYLIST_INSERTANDGO =$0009;
PLAYLIST_END =-666;
function VLC_Version ( ):PChar;cdecl;
function VLC_CompileTime ():PChar;cdecl;
function VLC_CompileBy ( ):Pchar;cdecl;
function VLC_CompileHost ():Pchar;cdecl;
function VLC_CompileDomain ():Pchar;cdecl;
function VLC_Compiler ( ):Pchar;cdecl;
function VLC_Changeset ( ):Pchar;cdecl;
function VLC_Error ( i_err:integer ):PChar;cdecl;
function VLC_Create( ):integer;cdecl;
function VLC_Init( i_obj,i_argc:integer;ppsz_argv:PPChar ):integer;cdecl;
function VLC_AddIntf( i_obj:integer;psz_module:Pchar;b_block,b_play:vlc_bool_t ):integer;cdecl;
function VLC_Die( i_obj:integer ):integer;cdecl;
function VLC_CleanUp(i_obj:integer ):integer;cdecl;
function VLC_Destroy(i_obj:integer ):integer;cdecl;
function VLC_VariableSet( i_obj:integer; psz_var:PChar;value:vlc_value_t ):integer;cdecl;
function VLC_VariableGet( i_obj:integer; psz_var:PChar;var value:vlc_value_t ):integer;cdecl;
function VLC_VariableType( i_obj:integer; psz_var:PChar;var pi_type:integer ):integer;cdecl;
function VLC_AddTarget(i_object:integer;psz_target:Pchar;ppsz_options:PPChar;
i_options,i_mode,i_pos:integer ):integer;cdecl;
function VLC_Play( i_obj:integer ):integer;cdecl;
function VLC_Pause( i_obj:integer ):integer;cdecl;
function VLC_Stop( i_obj:integer ):integer;cdecl;
function VLC_IsPlaying( i_obj:integer ):vlc_bool_t;cdecl;
function VLC_PositionGet( i_obj:integer ):single;cdecl;
function VLC_PositionSet( i_obj:integer;pos:single ):single;cdecl;
function VLC_TimeGet( i_obj:integer ):integer;cdecl;
function VLC_TimeSet( i_obj,i_seconds:integer;b_relative:vlc_bool_t ):integer;cdecl;
function VLC_LengthGet( i_obj:integer ):integer;cdecl;
function VLC_SpeedFaster( i_obj:integer ):Single;cdecl;
function VLC_SpeedSlower( i_obj:integer ):Single;cdecl;
function VLC_PlaylistIndex( i_obj:integer ):integer;cdecl;
function VLC_PlaylistNumberOfItems( i_obj:integer ):integer;cdecl;
function VLC_PlaylistNext( i_obj:integer ):integer;cdecl;
function VLC_PlaylistPrev( i_obj:integer ):integer;cdecl;
function VLC_PlaylistClear( i_obj:integer ):integer;cdecl;
function VLC_VolumeSet( i_obj,volume:integer):integer;cdecl;
function VLC_VolumeGet( i_obj:integer):integer;cdecl;
function VLC_VolumeMute( i_obj:integer):integer;cdecl;
function VLC_FullScreen( i_obj:integer):integer;cdecl;
implementation
const
VLC_DLL='libvlc.dll';
function vlc_int(val:integer):vlc_value_t;
type P=^integer;
begin
FillChar(Result,sizeof(vlc_value_t),0);
P(@Result)^ := val;
end;
function vlc_int(const val:vlc_value_t):integer;
type P=^integer;
begin
Result := P(@val)^;
end;
function vlc_bool(val:vlc_bool_t):vlc_value_t;
type P=^vlc_bool_t;
begin
FillChar(Result,sizeof(vlc_value_t),0);
P(@Result)^ := val;
end;
function vlc_bool(const val:vlc_value_t):vlc_bool_t;
type P=^vlc_bool_t;
begin
Result := P(@val)^;
end;
function vlc_pchar(val:Pchar):vlc_value_t;
type P=^Pchar;
begin
FillChar(Result,sizeof(vlc_value_t),0);
P(@Result)^ := val;
end;
function vlc_pchar(const val:vlc_value_t):PChar;
type P=^Pchar;
begin
Result := P(@val)^;
end;
function vlc_time(val:vlc_int64_t):vlc_value_t;
type P=^vlc_int64_t;
begin
FillChar(Result,sizeof(vlc_value_t),0);
P(@Result)^ := val;
end;
function vlc_time(const val:vlc_value_t):vlc_int64_t;
type P=^vlc_int64_t;
begin
Result := P(@val)^;
end;
function VLC_Version ( ):PChar;external VLC_DLL;
function VLC_CompileTime ():PChar;external VLC_DLL;
function VLC_CompileBy ( ):Pchar;external VLC_DLL;
function VLC_CompileHost ():Pchar;external VLC_DLL;
function VLC_CompileDomain ():Pchar;external VLC_DLL;
function VLC_Compiler ( ):Pchar;external VLC_DLL;
function VLC_Changeset ( ):Pchar;external VLC_DLL;
function VLC_Error ( i_err:integer ):PChar;external VLC_DLL;
function VLC_Create( ):integer;external VLC_DLL;
function VLC_Init( i_obj,i_argc:integer;ppsz_argv:PPChar ):integer;external VLC_DLL;
function VLC_AddIntf( i_obj:integer;psz_module:Pchar;b_block,b_play:vlc_bool_t ):integer;external VLC_DLL;
function VLC_Die( i_obj:integer ):integer;external VLC_DLL;
function VLC_CleanUp(i_obj:integer ):integer;external VLC_DLL;
function VLC_Destroy(i_obj:integer ):integer;external VLC_DLL;
function VLC_VariableSet( i_obj:integer; psz_var:PChar;value:vlc_value_t ):integer;external VLC_DLL;
function VLC_VariableGet( i_obj:integer; psz_var:PChar;var value:vlc_value_t ):integer;external VLC_DLL;
function VLC_VariableType( i_obj:integer; psz_var:PChar;var pi_type:integer ):integer;external VLC_DLL;
function VLC_AddTarget(i_object:integer;psz_target:Pchar;ppsz_options:PPChar;
i_options,i_mode,i_pos:integer ):integer;external VLC_DLL;
function VLC_Play( i_obj:integer ):integer;external VLC_DLL;
function VLC_Pause( i_obj:integer ):integer;external VLC_DLL;
function VLC_Stop( i_obj:integer ):integer;external VLC_DLL;
function VLC_IsPlaying( i_obj:integer ):vlc_bool_t;external VLC_DLL;
function VLC_PositionGet( i_obj:integer ):single;external VLC_DLL;
function VLC_PositionSet( i_obj:integer;pos:single ):single;external VLC_DLL;
function VLC_TimeGet( i_obj:integer ):integer;external VLC_DLL;
function VLC_TimeSet( i_obj,i_seconds:integer;b_relative:vlc_bool_t ):integer;external VLC_DLL;
function VLC_LengthGet( i_obj:integer ):integer;external VLC_DLL;
function VLC_SpeedFaster( i_obj:integer ):Single;external VLC_DLL;
function VLC_SpeedSlower( i_obj:integer ):Single;external VLC_DLL;
function VLC_PlaylistIndex( i_obj:integer ):integer;external VLC_DLL;
function VLC_PlaylistNumberOfItems( i_obj:integer ):integer;external VLC_DLL;
function VLC_PlaylistNext( i_obj:integer ):integer;external VLC_DLL;
function VLC_PlaylistPrev( i_obj:integer ):integer;external VLC_DLL;
function VLC_PlaylistClear( i_obj:integer ):integer;external VLC_DLL;
function VLC_VolumeSet( i_obj,volume:integer):integer;external VLC_DLL;
function VLC_VolumeGet( i_obj:integer):integer;external VLC_DLL;
function VLC_VolumeMute( i_obj:integer):integer;external VLC_DLL;
function VLC_FullScreen( i_obj:integer):integer;external VLC_DLL;
end.
Code: Select all
unit vlcwrap;
interface
uses vlc,SysUtils,Classes,Windows,Forms,extctrls,Variants;
const
VlcPlayListInsert = PLAYLIST_INSERT;
VlcPlayListInsertAndGo = PLAYLIST_INSERT+PLAYLIST_GO;
type
TVLCPlugin=class
private
Panel:TPanel;
handle:THandle;
i_object:integer;
function getVolume: integer;
procedure setVolume(const Value: integer);
function getVisible: boolean;
procedure setVisible(const Value: boolean);
function getLength: integer;
function getTime: integer;
procedure setTime(const Value: integer);
function getPlaying: boolean;
public
constructor Create(Panel:TPanel);
destructor Destroy;override;
property Volume:integer read getVolume write setVolume;
property Visible:boolean read getVisible write setVisible;
property Time:integer read getTime write setTime;
property Length:integer read getLength;
property Playing:boolean read getPlaying;
procedure play;
procedure pause;
procedure stop;
procedure shuttle(seconds:integer);
procedure playFaster;
procedure playSlower;
procedure playListClear;
function AddTarget(psz_target:string;options:Variant;
i_mode,i_pos:integer ):integer;cdecl;
end;
implementation
{ TVLCPlugin }
function TVLCPlugin.AddTarget(psz_target: string; options: Variant;
i_mode,i_pos: integer): integer;
begin
assert(options=null,'Options not supported');
VLC_AddTarget(i_object,Pchar(psz_target),nil,0,i_mode,-666);
end;
constructor TVLCPlugin.Create(Panel: TPanel);
label ERROR;
var
psz_option:PChar;
i_result:integer;
val:vlc_value_t;
msg:string;
begin
inherited Create;
Self.Panel := Panel;
Handle:=Panel.Handle;
i_object := VLC_Create();
psz_option := 'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe';
i_result := VLC_Init(i_object,1,@psz_option);
if i_result<0 then goto ERROR;
i_result :=VLC_VariableSet(i_object,'conf::width',vlc_int(Panel.Width));
if i_result<0 then goto ERROR;
i_result :=VLC_VariableSet(i_object,'conf::height',vlc_int(Panel.Height));
if i_result<0 then goto ERROR;
i_result :=VLC_VariableSet(i_object,'drawable',vlc_int(Panel.Handle));
if i_result<0 then goto ERROR;
i_result := VLC_VariableGet(i_object,'drawable',val);
if i_result<0 then goto ERROR;
exit;
ERROR:
msg := 'Error '+IntToStr(i_result) + ' :';
msg := msg + VLC_ERROR(i_result);
MessageBox(handle,Pchar(msg),'error',MB_ICONWARNING);
exit;
end;
destructor TVLCPlugin.destroy;
begin
VLC_CleanUp(i_object);
VLC_Destroy(i_object);
inherited;
end;
function TVLCPlugin.getLength: integer;
begin
Result := VLC_LengthGet(i_object);
end;
function TVLCPlugin.getPlaying: boolean;
begin
Result := VLC_IsPlaying(i_object)<>VLC_FALSE;
end;
function TVLCPlugin.getTime: integer;
begin
Result := VLC_TimeGet(i_object);
end;
function TVLCPlugin.getVisible: boolean;
begin
Result := Panel.Visible;
end;
function TVLCPlugin.getVolume: integer;
begin
Result := VLC_VolumeGet(i_object);
end;
procedure TVLCPlugin.pause;
begin
VLC_pause(i_object);
end;
procedure TVLCPlugin.play;
begin
VLC_Play(i_object);
end;
procedure TVLCPlugin.playFaster;
begin
VLC_SpeedFaster(i_object);
end;
procedure TVLCPlugin.playListClear;
begin
VLC_PlayListClear(i_object);
end;
procedure TVLCPlugin.playSlower;
begin
VLC_SpeedSlower(i_object);
end;
procedure TVLCPlugin.setTime(const Value: integer);
begin
VLC_TimeSet(i_object,Value,VLC_FALSE);
end;
procedure TVLCPlugin.setVisible(const Value: boolean);
begin
Panel.Visible := Value;
end;
procedure TVLCPlugin.setVolume(const Value: integer);
begin
VLC_volumeSet(i_object,Value);
end;
procedure TVLCPlugin.shuttle(seconds: integer);
begin
VLC_TimeSet(i_object,seconds,VLC_TRUE);
end;
procedure TVLCPlugin.stop;
begin
VLC_Stop(i_object);
end;
Code: Select all
val.AsPChar:= 'goom';
call('VLC_VariableSet',VLC_VariableSet(vlc,'conf::audio-visual',val));
Code: Select all
val.AsPChar:= '0';
call('VLC_VariableSet',VLC_VariableSet(vlc,'conf::audio-visual',val));
Code: Select all
vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf,
VLC_OBJECT_VOUT, FIND_ANYWHERE);
if( p_vout == NULL )
{
switch( event.GetId() )
{
case Hue_Event:
config_PutInt( p_intf , "hue" , event.GetPosition() );
break;
...............
}
Users browsing this forum: No registered users and 28 guests