Code: Select all
program Test;
function AllocConsole:LongBool; stdcall; external 'kernel32.dll';
function libvlc_new(argc:integer; args:ppchar):pointer; cdecl; external 'libvlc.dll';
function libvlc_media_new_path(vlc: pointer; mrl : pchar):pointer;cdecl; external 'libvlc.dll';
function libvlc_media_player_new_from_media(media: pointer): pointer; cdecl; external 'libvlc.dll';
procedure libvlc_media_player_play(mediaplayer: pointer); cdecl; external 'libvlc.dll';
procedure libvlc_audio_set_volume(mediaplayer: pointer; volume:integer); cdecl; external 'libvlc.dll';
var
args:array of pchar;
fn:string;
v:integer;
p_libvlc,p_media,p_player:pointer;
begin
AllocConsole;
SetLength(args,5);
args[0]:=pchar('--plugin-path=..\plugins');
args[1]:=pchar('--no-osd');
args[2]:=pchar('--no-media-library');
args[3]:=pchar('--no-video-title-show');
args[4]:=nil;
p_libvlc:=libvlc_new(System.Length(args)-1,@args[0]);
if p_libvlc=nil then begin WriteLn('p_libvlc is nil');ReadLn;Halt;end;
fn:='e:\bla-bla.avi'; // whatever
p_media:=libvlc_media_new_path(p_libvlc,pchar(fn));
if p_media=nil then begin WriteLn('p_media is nil');ReadLn;Halt;end;
p_player:=libvlc_media_player_new_from_media(p_media);
if p_player=nil then begin WriteLn('p_player is nil');ReadLn;Halt;end;
libvlc_media_player_play(p_player);
WriteLn('Press ENTER when video playback starts');
ReadLn;
v:=30;
libvlc_audio_set_volume(p_player,v); // crash right here with error 207 (floating point) from libvlccore
WriteLn('Vol 30');
ReadLn;
v:=50;
libvlc_audio_set_volume(p_player,v);
WriteLn('Vol 50');
WriteLn('Press ENTER to end');
ReadLn;
end.
Code: Select all
int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
{
float vol = volume / 100.f;
if (vol < 0.f)
{
libvlc_printerr( "Volume out of range" );
return -1;
}
int ret = -1;
audio_output_t *aout = GetAOut( mp );
if( aout != NULL )
{
ret = aout_VolumeSet( aout, vol );
vlc_object_release( aout );
}
return ret;
}
Code: Select all
int aout_VolumeSet (audio_output_t *aout, float vol)
{
aout_owner_t *owner = aout_owner (aout);
assert (vol >= 0.f);
vlc_mutex_lock (&owner->req.lock);
owner->req.volume = vol;
vlc_mutex_unlock (&owner->req.lock);
if (aout_OutputTryLock (aout) == 0)
aout_OutputUnlock (aout);
return 0;
}
Code: Select all
Set8087CW((Get8087CW and $FFC0) or $003F);
Return to “Development around libVLC”
Users browsing this forum: No registered users and 7 guests