Hello,
I'm a french developper.
I have begun a unit libvlc.pas for vlc0.9.2. I don't finish it :
Code: Select all
unit libVLC;
{ VideoLAN libvcl.dll (0.8.6b) Interface for Delphi (c)2007 by Paul TOTH
- Modified by Keypad libvcl.dll (0.9.2) }
// http://wiki.videolan.org/ExternalAPI#VLC_Control
interface
uses QDialogs, sysutils, forms;
const
LibName = 'libvlc.dll';
// Structures
type
libvlc_exception= record
Code : integer;
Message : pchar;
end;
libvlc_media_discoverer = pointer;
libvlc_media_list = pointer;
libvlc_media_list_player = pointer;
libvlc_media_player = pointer;
libvlc_media = pointer;
libvlc_instance = pointer;
libvlc_input = pointer;
{$IFDEF STATIC}
// Core
function libvlc_new(argc:integer; args:ppchar; var exception:libvlc_exception):libvlc_instance; cdecl external lib;
procedure libvlc_destroy(vlc:libvlc_instance); cdecl external lib;
procedure libvlc_exception_clear(var exception:libvlc_exception); cdecl external lib;
// Media
function libvlc_media_new(vlc: libvlc_instance; var mrl : pchar; var exception:libvlc_exception):libvlc_media;cdecl external lib;
procedure libvlc_media_release(media : libvlc_media); cdecl external lib;
function libvlc_media_add_option(media : libvlc_media; var options : pchar; var exception:libvlc_exception):integer; cdecl external lib;
// Media player
procedure libvlc_media_player_play(mediaplayer: libvlc_media_player;var exception:libvlc_exception); cdecl external lib;
procedure libvlc_media_player_release(mediaplayer : libvlc_media_player); cdecl external lib;
function libvlc_media_player_new_from_media(media: libvlc_media;var exception:libvlc_exception): libvlc_media_player; cdecl external lib;
function libvlc_media_player_new(vlc: libvlc_instance; var exception:libvlc_exception):libvlc_media_player;cdecl external lib;
function libvlc_media_player_get_length(mediaplayer : libvlc_media_player; var exception : libvlc_exception):int64;cdecl external lib;
function libvlc_media_player_get_time(mediaplayer : libvlc_media_player; var exception : libvlc_exception):int64;cdecl external lib;
function libvlc_media_player_get_position(mediaplayer : libvlc_media_player; var exception : libvlc_exception):single;cdecl external lib;
function libvlc_media_player_stop(mediaplayer: libvlc_media_player;var exception:libvlc_exception);cdecl external lib;
function libvlc_media_player_pause(mediaplayer: libvlc_media_player;var exception:libvlc_exception);cdecl external lib;
procedure libvlc_media_player_set_position(mediaplayer : libvlc_media_player; position : single; var exception : libvlc_exception);cdecl external lib;
procedure libvlc_media_player_set_time(mediaplayer : libvlc_media_player; timeset : integer; var exception : libvlc_exception);cdecl external lib;
// Media List Player (ancien playlist)
function libvlc_media_list_player_new(vlc: libvlc_instance; var exception:libvlc_exception):libvlc_media_list_player;cdecl external lib;
procedure libvlc_media_list_player_release(medialistplayer :libvlc_media_list_player);cdecl external lib;
procedure libvlc_media_list_player_set_media_player(medialistplayer :libvlc_media_list_player; mediaplayer : libvlc_media_player; var exception:libvlc_exception);cdecl external lib;
procedure libvlc_media_list_player_play(medialistplayer :libvlc_media_list_player; var exception:libvlc_exception);cdecl external lib;
function libvlc_media_list_new(vlc: libvlc_instance; var exception:libvlc_exception):libvlc_media_list;cdecl external lib;
procedure libvlc_media_list_add_file_content(medialist: libvlc_media_list; filename : pchar; var exception:libvlc_exception);cdecl external lib;
procedure libvlc_media_list_player_set_media_list(medialistplayer :libvlc_media_list_player;medialist: libvlc_media_list;var exception:libvlc_exception);cdecl external lib;
procedure libvlc_media_list_player_next(medialistplayer :libvlc_media_list_player;var exception:libvlc_exception);cdecl external lib;
function libvlc_media_list_count(medialist: libvlc_media_list;var exception:libvlc_exception):int64;cdecl external lib;
function libvlc_media_discoverer_new_from_name(vlc: libvlc_instance; filename : pchar; var exception:libvlc_exception):libvlc_media_discoverer;cdecl external lib;
function libvlc_media_discoverer_media_list(mediadiscoverer: libvlc_media_discoverer;var exception:libvlc_exception) : libvlc_media_list;cdecl external lib;
procedure libvlc_media_list_add_media(medialist: libvlc_media_list; media : libvlc_media; var exception:libvlc_exception);cdecl external lib;
procedure libvlc_media_list_lock(medialist: libvlc_media_list);cdecl external lib;
// Playlist
function libvlc_playlist_add(vlc:libvlc_instance; fileName,name:pchar; var exception:libvlc_exception):integer; cdecl external lib;
function libvlc_playlist_add_extended(vlc:libvlc_instance; fileName,name:pchar; optCount:integer; opts:ppchar; var exception:libvlc_exception):integer; cdecl external lib;
procedure libvlc_playlist_clear(vlc:libvlc_instance; var exception:libvlc_exception); cdecl external lib;
function libvlc_playlist_items_count(vlc:libvlc_instance; var exception:libvlc_exception):integer; cdecl external lib;
function libvlc_playlist_isplaying(vlc:libvlc_instance; var exception:libvlc_exception):longbool; cdecl external lib;
procedure libvlc_playlist_play(vlc:libvlc_instance; index,optCount:integer; opts:ppchar; var exception:libvlc_exception); cdecl external lib;
procedure libvlc_playlist_pause(vlc:libvlc_instance; var exception:libvlc_exception); cdecl external lib;
procedure libvlc_playlist_stop(vlc:libvlc_instance; var exception:libvlc_exception); cdecl external lib;
procedure libvlc_playlist_next(vlc:libvlc_instance; var exception:libvlc_exception); cdecl external lib;
procedure libvlc_playlist_prev(vlc:libvlc_instance; var exception:libvlc_exception); cdecl external lib;
function libvlc_playlist_get_input(vlc:libvlc_instance; var exception:libvlc_exception):libvlc_input; cdecl external lib;
function libvlc_playlist_get_media_player(vlc:libvlc_instance; var exception:libvlc_exception):libvlc_media_player; cdecl external lib;
// Input
procedure libvlc_input_free(input:libvlc_input); cdecl external lib;
procedure libvlc_toggle_fullscreen(input:libvlc_input; var exception:libvlc_exception); cdecl external lib;
// Video
function libvlc_video_get_width(input:libvlc_input; var exception:libvlc_exception):integer; cdecl external lib;
function libvlc_video_get_height(input:libvlc_input; var exception:libvlc_exception):integer; cdecl external lib;
procedure libvlc_set_fullscreen(mediaplayer : libvlc_media_player; fullscreen : integer; var exception:libvlc_exception); cdecl external lib;
function libvlc_get_fullscreen(mediaplayer : libvlc_media_player; var exception:libvlc_exception): integer; cdecl external lib;
procedure libvlc_video_take_snapshot(mediaplayer : libvlc_media_player; filepath : pchar; var width : integer; var height : integer;var exception:libvlc_exception); cdecl external lib;
// Audio
function libvlc_audio_get_mute(vlc:libvlc_instance; var exception:libvlc_exception):longbool; cdecl external lib;
procedure libvlc_audio_set_mute(vlc:libvlc_instance; mute:longbool; var exception:libvlc_exception); cdecl external lib;
function libvlc_audio_get_volume(vlc:libvlc_instance; var exception:libvlc_exception):integer; cdecl external lib;
procedure libvlc_audio_set_volume(vlc:libvlc_instance; volume:integer; var exception:libvlc_exception); cdecl external lib;
//Other
procedure libvlc_video_set_parent(vlc:libvlc_instance; libvlc_drawable_t:integer; var exception:libvlc_exception); cdecl external lib;
//function libvlc_video_get_parent(vlc:libvlc_instance; var exception:libvlc_exception):integer; cdecl external lib;
{$ELSE}
var
// Core
libvlc_new:function(argc:integer; args:ppchar; var exception:libvlc_exception):libvlc_instance; cdecl;
libvlc_destroy:procedure(vlc:libvlc_instance); cdecl;
libvlc_exception_clear:procedure(var exception:libvlc_exception); cdecl;
// media
libvlc_media_new:function(vlc: libvlc_instance; mrl : pchar; var exception:libvlc_exception):libvlc_media;cdecl;
libvlc_media_release: procedure(media : libvlc_media); cdecl;
libvlc_media_add_option: function(media : libvlc_media; options : pchar; var exception:libvlc_exception):integer; cdecl;
// media player
libvlc_media_player_play: procedure(mediaplayer: libvlc_media_player;var exception:libvlc_exception); cdecl;
libvlc_media_player_new_from_media : function(media: libvlc_media;var exception:libvlc_exception): libvlc_media_player; cdecl;
libvlc_media_player_release: procedure(mediaplayer : libvlc_media_player); cdecl;
libvlc_media_player_new: function(vlc: libvlc_instance; var exception:libvlc_exception):libvlc_media_player;cdecl;
libvlc_media_player_get_length: function(mediaplayer : libvlc_media_player; var exception : libvlc_exception):int64;cdecl;
libvlc_media_player_get_time: function(mediaplayer : libvlc_media_player; var exception : libvlc_exception):int64;cdecl;
libvlc_media_player_get_position: function(mediaplayer : libvlc_media_player; var exception : libvlc_exception):single;cdecl;
libvlc_media_player_stop: procedure(mediaplayer: libvlc_media_player;var exception:libvlc_exception); cdecl;
libvlc_media_player_pause: procedure(mediaplayer: libvlc_media_player;var exception:libvlc_exception); cdecl;
libvlc_media_player_set_position: procedure(mediaplayer : libvlc_media_player; position : single; var exception : libvlc_exception);cdecl ;
libvlc_media_player_set_time: procedure(mediaplayer : libvlc_media_player; timeset : integer; var exception : libvlc_exception);cdecl;
// media list (ancien playlist)
libvlc_media_list_player_new: function(vlc: libvlc_instance; var exception:libvlc_exception):libvlc_media_list_player;cdecl ;
libvlc_media_list_player_release: procedure(medialistplayer :libvlc_media_list_player);cdecl;
libvlc_media_list_player_set_media_player: procedure(medialistplayer :libvlc_media_list_player; mediaplayer : libvlc_media_player; var exception:libvlc_exception);cdecl ;
libvlc_media_list_player_play: procedure(medialistplayer :libvlc_media_list_player; var exception:libvlc_exception);cdecl ;
libvlc_media_list_new: function(vlc: libvlc_instance; var exception:libvlc_exception):libvlc_media_list;cdecl ;
libvlc_media_list_add_file_content: procedure(medialist: libvlc_media_list; filename : pchar; var exception:libvlc_exception);cdecl ;
libvlc_media_list_player_set_media_list : procedure(medialistplayer :libvlc_media_list_player;medialist: libvlc_media_list;var exception:libvlc_exception);cdecl ;
libvlc_media_list_player_next : procedure(medialistplayer :libvlc_media_list_player;var exception:libvlc_exception);cdecl ;
libvlc_media_list_count: function(medialist: libvlc_media_list;var exception:libvlc_exception):int64;cdecl ;
libvlc_media_discoverer_new_from_name: function(vlc: libvlc_instance; filename : pchar; var exception:libvlc_exception):libvlc_media_discoverer;cdecl;
libvlc_media_discoverer_media_list: function(mediadiscoverer: libvlc_media_discoverer;var exception:libvlc_exception) : libvlc_media_list;cdecl;
libvlc_media_list_add_media: procedure(medialist: libvlc_media_list; media : libvlc_media; var exception:libvlc_exception);cdecl;
libvlc_media_list_lock: procedure(medialist: libvlc_media_list);cdecl ;
// Playlist
libvlc_playlist_add:function(vlc:libvlc_instance; fileName,name:pchar; var exception:libvlc_exception):integer; cdecl;
libvlc_playlist_add_extended:function(vlc:libvlc_instance; fileName,name:pchar; optCount:integer; opts:ppchar; var exception:libvlc_exception):integer; cdecl;
libvlc_playlist_clear:procedure(vlc:libvlc_instance; var exception:libvlc_exception); cdecl;
libvlc_playlist_items_count:function(vlc:libvlc_instance; var exception:libvlc_exception):integer; cdecl;
libvlc_playlist_isplaying:function(vlc:libvlc_instance; var exception:libvlc_exception):longbool; cdecl;
libvlc_playlist_play:procedure(vlc:libvlc_instance; index,optCount:integer; opts:ppchar; var exception:libvlc_exception); cdecl;
libvlc_playlist_pause:procedure(vlc:libvlc_instance; var exception:libvlc_exception); cdecl;
libvlc_playlist_stop:procedure(vlc:libvlc_instance; var exception:libvlc_exception); cdecl;
libvlc_playlist_next:procedure(vlc:libvlc_instance; var exception:libvlc_exception); cdecl;
libvlc_playlist_prev:procedure(vlc:libvlc_instance; var exception:libvlc_exception); cdecl;
libvlc_playlist_get_input:function(vlc:libvlc_instance; var exception:libvlc_exception):libvlc_input; cdecl;
libvlc_playlist_get_media_player: function(vlc:libvlc_instance; var exception:libvlc_exception):libvlc_media_player; cdecl;
// Input (Vout)
libvlc_input_free:procedure(input:libvlc_input); cdecl;
libvlc_input_get_length:function(input:libvlc_input; var exception:libvlc_exception):int64; cdecl;
libvlc_input_get_time:function(input:libvlc_input; var exception:libvlc_exception):Int64; cdecl;
libvlc_input_get_position:function(input:libvlc_input; var exception:libvlc_exception):Single; cdecl;
libvlc_toggle_fullscreen:procedure(input:libvlc_input; var exception:libvlc_exception); cdecl;
libvlc_set_fullscreen: procedure(mediaplayer : libvlc_media_player; fullscreen : integer; var exception:libvlc_exception); cdecl ;
libvlc_get_fullscreen: function(mediaplayer : libvlc_media_player; var exception:libvlc_exception): integer; cdecl;
// Video
libvlc_video_get_width:function(input:libvlc_input; var exception:libvlc_exception):integer; cdecl;
libvlc_video_get_height:function(input:libvlc_input; var exception:libvlc_exception):integer; cdecl;
libvlc_video_set_parent:procedure(vlc:libvlc_instance; libvlc_drawable_t:integer; var exception:libvlc_exception); cdecl;
libvlc_video_get_parent:function(vlc:libvlc_instance; var exception:libvlc_exception):integer; cdecl;
libvlc_video_set_visual: function(vlc :libvlc_instance; var visual_id: integer;var exception:libvlc_exception):integer; cdecl;
libvlc_video_take_snapshot: procedure(mediaplayer : libvlc_media_player; filepath : pchar; width : integer; height : integer;var exception:libvlc_exception); cdecl;
// Audio
libvlc_audio_get_mute:function(vlc:libvlc_instance; var exception:libvlc_exception):longbool; cdecl;
libvlc_audio_set_mute:procedure(vlc:libvlc_instance; mute:longbool; var exception:libvlc_exception); cdecl;
libvlc_audio_get_volume:function(vlc:libvlc_instance; var exception:libvlc_exception):integer; cdecl;
libvlc_audio_set_volume:procedure(vlc:libvlc_instance; volume:integer; var exception:libvlc_exception); cdecl;
//Other
const
VLD_SUCCESS = 0;
VLD_NOLIB = -1;
VLD_NOTFOUND = -2;
// load libvlc.dll (get Install path from registry)
function VLD_LoadLibrary:integer;
// return Install path found in registry by VLD_LoadLibrary
function VLD_LibPath:string;
// return libvlc.dll proc adress
function VLD_GetProcAddress(Name:pchar; var addr:pointer):integer;
// return (and clear) last VLD error
function VLD_LastError:integer;
// load everything (dll & procs) and return last VLD error
function VLD_Startup:integer;
{$ENDIF}
implementation
{$IFNDEF STATIC}
uses
Windows;
var
LibVLCHandle: THandle = 0;
LibPath: string;
LastError: integer = VLD_SUCCESS;
VLCLibLoaded: boolean = false;
function GetLibPath: boolean;
var
racine : string;
Handle: HKEY;
RegType: integer;
DataSize: integer;
begin
Result := False;
// verifie si libvlc.dll existe
racine := ExtractFilePath(Application.ExeName);
if FileExists(racine + 'VLC\libvlc.dll') then
begin
result := true;
libPath := racine + 'VLC\';
end
else
begin
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, 'Software\VideoLAN\VLC', 0, KEY_ALL_ACCESS, Handle) = ERROR_SUCCESS) then
begin
if RegQueryValueEx(Handle, 'InstallDir', nil, @RegType, nil, @DataSize) = ERROR_SUCCESS then
begin
SetLength(LibPath, Datasize);
RegQueryValueEx(Handle, 'InstallDir', nil, @RegType, PByte(@LibPath[1]), @DataSize);
LibPath[DataSize] := '\';
Result := True;
end;
RegCloseKey(Handle);
end;
end;
end;
function VLD_LibPath: string;
begin
if LibPath = '' then
getLibPath;
Result := LibPath;
end;
function VLD_LoadLibrary:integer;
begin
if LibVLCHandle = 0 then
begin
LibVLCHandle := LoadLibrary(LibName);
if (LibVLCHandle = 0) and (getLibPath) then
LibVLCHandle := LoadLibrary(PChar(LibPath + LibName));
end;
if LibVLCHandle <> 0 then
Result := VLD_SUCCESS
else
begin
LastError := VLD_NOLIB;
Result := LastError;
end;
end;
function VLD_GetProcAddress(Name: PChar; var Addr: Pointer): Integer;
begin
if LibVLCHandle = 0 then
begin
Result := VLD_LoadLibrary;
if Result <> VLD_SUCCESS then exit;
end;
Addr := GetProcAddress(LibVLCHandle, Name);
if Addr <> nil then
Result := VLD_SUCCESS
else
begin
LastError := VLD_NOTFOUND;
Result := LastError;
end;
end;
function VLD_LastError: Integer;
begin
Result := LastError;
LastError := VLD_SUCCESS;
end;
function VLD_Startup: Integer;
begin
LastError := VLD_SUCCESS;
if VLD_LoadLibrary = VLD_SUCCESS then
begin
VLD_GetProcAddress('libvlc_new', @libvlc_new);
VLD_GetProcAddress('libvlc_exception_clear', @libvlc_exception_clear);
VLD_GetProcAddress('libvlc_playlist_add', @libvlc_playlist_add);
VLD_GetProcAddress('libvlc_playlist_add_extended', @libvlc_playlist_add_extended);
VLD_GetProcAddress('libvlc_playlist_clear', @libvlc_playlist_clear);
VLD_GetProcAddress('libvlc_playlist_items_count', @libvlc_playlist_items_count);
VLD_GetProcAddress('libvlc_playlist_isplaying', @libvlc_playlist_isplaying);
VLD_GetProcAddress('libvlc_playlist_play', @libvlc_playlist_play);
VLD_GetProcAddress('libvlc_playlist_pause', @libvlc_playlist_pause);
VLD_GetProcAddress('libvlc_playlist_stop', @libvlc_playlist_stop);
VLD_GetProcAddress('libvlc_playlist_next', @libvlc_playlist_next);
VLD_GetProcAddress('libvlc_playlist_prev', @libvlc_playlist_prev);
VLD_GetProcAddress('libvlc_media_new', @libvlc_media_new);
VLD_GetProcAddress('libvlc_media_release', @libvlc_media_release);
VLD_GetProcAddress('libvlc_media_add_option', @libvlc_media_add_option);
VLD_GetProcAddress('libvlc_media_player_release', @libvlc_media_player_release);
VLD_GetProcAddress('libvlc_media_player_new', @libvlc_media_player_new);
VLD_GetProcAddress('libvlc_media_player_new_from_media', @libvlc_media_player_new_from_media);
VLD_GetProcAddress('libvlc_media_player_play', @libvlc_media_player_play);
VLD_GetProcAddress('libvlc_media_player_get_length', @libvlc_media_player_get_length);
VLD_GetProcAddress('libvlc_media_player_get_time', @libvlc_media_player_get_time);
VLD_GetProcAddress('libvlc_media_player_get_position', @libvlc_media_player_get_position);
VLD_GetProcAddress('libvlc_media_player_set_time', @libvlc_media_player_set_time);
VLD_GetProcAddress('libvlc_media_player_set_position', @libvlc_media_player_set_position);
VLD_GetProcAddress('libvlc_media_player_stop', @libvlc_media_player_stop);
VLD_GetProcAddress('libvlc_media_player_play', @libvlc_media_player_play);
VLD_GetProcAddress('libvlc_media_player_pause', @libvlc_media_player_pause);
VLD_GetProcAddress('libvlc_toggle_fullscreen', @libvlc_toggle_fullscreen);
VLD_GetProcAddress('libvlc_video_get_width', @libvlc_video_get_width);
VLD_GetProcAddress('libvlc_video_get_height', @libvlc_video_get_height);
VLD_GetProcAddress('libvlc_set_fullscreen', @libvlc_set_fullscreen);
VLD_GetProcAddress('libvlc_get_fullscreen', @libvlc_get_fullscreen);
VLD_GetProcAddress('libvlc_audio_get_mute', @libvlc_audio_get_mute);
VLD_GetProcAddress('libvlc_audio_set_mute', @libvlc_audio_set_mute);
VLD_GetProcAddress('libvlc_audio_get_volume', @libvlc_audio_get_volume);
VLD_GetProcAddress('libvlc_audio_set_volume', @libvlc_audio_set_volume);
VLD_GetProcAddress('libvlc_video_set_parent', @libvlc_video_set_parent);
VLD_GetProcAddress('libvlc_video_take_snapshot', @libvlc_video_take_snapshot);
VLD_GetProcAddress('libvlc_media_list_player_new', @libvlc_media_list_player_new);
VLD_GetProcAddress('libvlc_media_list_player_release', @libvlc_media_list_player_release);
VLD_GetProcAddress('libvlc_media_list_player_set_media_player', @libvlc_media_list_player_set_media_player);
VLD_GetProcAddress('libvlc_media_list_new', @libvlc_media_list_new);
VLD_GetProcAddress('libvlc_media_list_player_set_media_list', @libvlc_media_list_player_set_media_list);
VLD_GetProcAddress('libvlc_media_list_add_file_content', @libvlc_media_list_add_file_content);
VLD_GetProcAddress('libvlc_media_list_player_next', @libvlc_media_list_player_next);
VLD_GetProcAddress('libvlc_media_list_player_play', @libvlc_media_list_player_play);
VLD_GetProcAddress('libvlc_media_list_count', @libvlc_media_list_count);
VLD_GetProcAddress('libvlc_media_discoverer_new_from_name', @libvlc_media_discoverer_new_from_name);
VLD_GetProcAddress('libvlc_media_discoverer_media_list', @libvlc_media_discoverer_media_list);
VLD_GetProcAddress('libvlc_media_list_add_media', @libvlc_media_list_add_media);
VLD_GetProcAddress('libvlc_media_list_lock', @libvlc_media_list_lock);
//VLD_GetProcAddress('libvlc_media_descriptor_new', @libvlc_media_descriptor_new);
//VLD_GetProcAddress('libvlc_media_list_add', @libvlc_media_list_add);
//VLD_GetProcAddress('libvlc_media_descriptor_release', @libvlc_media_descriptor_release);
//VLD_GetProcAddress('libvlc_media_list_player_play_item_at_index', @libvlc_media_list_player_play_item_at_index);
// VLD_GetProcAddress('libvlc_media_list_player_stop', @libvlc_media_list_player_stop);
VLCLibLoaded := true;
end;
Result := LastError;
end;
{$ENDIF}
end.
And i'm coding a player TFPPlayer.pas which use this libvlc.pas...
You have to put the VLC directory in your application directory
I just have a problem for playlists because libvlc.dll use media list :
viewtopic.php?f=14&t=50069