Recent

Author Topic: Execute VLC  (Read 2279 times)

amedeo

  • New Member
  • *
  • Posts: 16
Execute VLC
« on: March 09, 2021, 11:09:37 am »
Hallo people can you help me?
I start VLC from my program in this way:

Code: Pascal  [Select][+][-]
  1. var
  2.   AProcess: TProcess;
  3. begin
  4.   AProcess := TProcess.Create(nil);
  5.   AProcess.Executable:='/usr/bin/vlc';
  6.   AProcess.Options := AProcess.Options + [poWaitOnExit];
  7.   AProcess.Execute;
  8.   AProcess.Free;

It works good but after I have to search the song to play inside VLC.
I should like to start the song from inside program setting its location+name but in this way the program doesn't work.
Somebody knows how to do it?
Thanks a lot.
Amedeo

[Edited to add code tags; please see How to use the Forum.]
« Last Edit: March 09, 2021, 11:38:30 am by trev »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Execute VLC
« Reply #1 on: March 09, 2021, 11:59:12 am »
This should be enough:

Code: Pascal  [Select][+][-]
  1. procedure PlayFile(const Filename: String);
  2. var
  3.   AProcess: TProcess;
  4. begin
  5.   AProcess := TProcess.Create(nil);
  6.   AProcess.Executable:='/usr/bin/vlc';
  7.   AProcess.Parameters.Clear; {Murphy guard}
  8.   AProcess.Parameters.Add(Filename)
  9.   AProcess.Options := AProcess.Options + [poWaitOnExit];
  10.   AProcess.Execute;
  11.   AProcess.Free;
  12. end;
« Last Edit: March 09, 2021, 03:44:31 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

amedeo

  • New Member
  • *
  • Posts: 16
Re: Execute VLC
« Reply #2 on: March 09, 2021, 03:14:59 pm »
It'ok, thanks :D

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9533
  • FPC developer.
Re: Execute VLC
« Reply #3 on: March 09, 2021, 03:24:24 pm »
Or simply

Code: Pascal  [Select][+][-]
  1. Runcommand('/usr/bin/vlc',[filename]);

cdbc

  • Sr. Member
  • ****
  • Posts: 361
    • http://www.cdbc.dk
Re: Execute VLC
« Reply #4 on: March 09, 2021, 07:56:06 pm »
Hi
If you don't need the vlc gui, you could try 'cvlc' it just plays your song... Just saying  :)
Regards Benny
If it ain't broke, don't fix it ;)

 

TinyPortal © 2005-2018