Recent

Author Topic: omxplayer using lazarus  (Read 7401 times)

hamza

  • Jr. Member
  • **
  • Posts: 52
omxplayer using lazarus
« on: March 27, 2015, 02:10:52 am »
Hi to all

How can i open a vedio .mp4 using omxplayer and pascal lazarus??

Any example plz??

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: omxplayer using lazarus
« Reply #1 on: March 27, 2015, 08:22:53 pm »
The following code is completely untested, and I've never used Raspberry Pi.  The simplest way might just be...

Code: [Select]
Uses
  Process;
...
Var
  sOutput: String;
Begin
  RunCommand('omxplayer', ['/path/to/video/vedio.mp4'], sOutput);
End;

Although this answers your question, you're probably after a more embedded use...   A minimal 5 second google suggests to me omxplayer isn't for playing embedded video in an app (though I may be wrong)...   If that's what you're after, then is MPlayer available on Raspberry instead?

Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

hamza

  • Jr. Member
  • **
  • Posts: 52
Re: omxplayer using lazarus
« Reply #2 on: March 29, 2015, 11:36:49 pm »
Thank u for your support and i will test your code

I have a problem with mplayer becouse it is running mp4   vedio very slowly and i dont know what is the problem.
but when i run the same vedio with oxmplayer( using command terminal ..it is working normally...

parcel

  • Full Member
  • ***
  • Posts: 143
Re: omxplayer using lazarus
« Reply #3 on: March 30, 2015, 01:09:27 am »
In other way, OPENELEC is best solution for media OS.
It playing most of formats without problem.

http://openelec.tv/

hamza

  • Jr. Member
  • **
  • Posts: 52
Re: omxplayer using lazarus
« Reply #4 on: April 01, 2015, 08:56:52 pm »
The following code is completely untested, and I've never used Raspberry Pi.  The simplest way might just be...

Code: [Select]
Uses
  Process;
...
Var
  sOutput: String;
Begin
  RunCommand('omxplayer', ['/path/to/video/vedio.mp4'], sOutput);
End;


Although this answers your question, you're probably after a more embedded use...   A minimal 5 second google suggests to me omxplayer isn't for playing embedded video in an app (though I may be wrong)...   If that's what you're after, then is MPlayer available on Raspberry instead?

I tried your code but it seems not working  but this error appeared

my prog


unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, process, FileUtil, Forms, Controls, Graphics, Dialogs,
  StdCtrls, UTF8Process;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Process1: TProcess;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
  Var
  sOutput: String;
Begin
  RunCommand('omxplayer', ['/home/pi/Cc.mp4'], sOutput);


end;

end.   


 and error message was
unit1.pas(39,13) Error: Identifier not found "RunCommand"
unit1.pas(46) Fatal: There were 1 errors compiling module, stopping

how can we solve this problem???

thanks in advance


Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: omxplayer using lazarus
« Reply #5 on: April 01, 2015, 10:27:14 pm »
Quote
how can we solve this problem???

By being more careful when copying code from the forum :-)

I said to use Process, not UTF8Process.  They're different units with different functionality. 
In this case, the difference is the lack of the RunCommand helper routines in UTF8Process.  Switch it back and my code *should* work. (Sure, it's still not tested, so this is a brave call for me to make :-) )

If you need UTF8Process, then have a look in Process.pp, and port RunCommand :-)
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

hamza

  • Jr. Member
  • **
  • Posts: 52
Re: omxplayer using lazarus
« Reply #6 on: April 25, 2015, 07:36:01 pm »
sorry for late reply but I change the processor but still have problem.
firstly I have the folowing
lazarus  version 0.9.30.4-6
FPC 2.6.0
ARM LINUX gtk 2

then I tried the suggested code
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, process, LCLIntf, FileUtil, Forms, Controls, Graphics,
  Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    RunCommand: TProcess;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
Var
  sOutput: String;
Begin
  RunCommand('omxplayer', ['/home/ppp1/Desktop/Clow.mp4'], sOutput);

end;

end.

but this error appeared(error **on RunCommand('omxplayer', ['/home/ppp1/Desktop/Clow.mp4'], sOutput);**
ERROR : illegal expression


also how can I update fpc and pascal??? in case there are new software??
 

parcel

  • Full Member
  • ***
  • Posts: 143
Re: omxplayer using lazarus
« Reply #7 on: April 26, 2015, 01:07:45 am »
How about using full path of omxplayer?

You get it from
Code: [Select]
which omxplayer

hamza

  • Jr. Member
  • **
  • Posts: 52
Re: mplayer using lazarus
« Reply #8 on: April 26, 2015, 10:15:19 am »

I used mplayer and omxplayer with full path but still have the same error[illegal expression]

anyway I serached on Google and i find that the RunCommand need FPC 2.6.2, but i have FPC 2.6.0 ??
http://wiki.freepascal.org/Executing_External_Programs

so, if this correct, how can i fpc 2.6.2??

hamza

  • Jr. Member
  • **
  • Posts: 52
Re: omxplayer using lazarus
« Reply #9 on: April 28, 2015, 06:36:52 pm »
can you help me plz~??

 

TinyPortal © 2005-2018