Recent

Author Topic: Delphi > Lazarus htm, mp3, avi, jpeg  (Read 12157 times)

klodovik

  • Newbie
  • Posts: 1
Delphi > Lazarus htm, mp3, avi, jpeg
« on: March 23, 2006, 03:58:05 pm »
Hi,
I used Delphi and I will use Lazarus in near future.

Is it possible (and how) with Lazarus to:
1. play mp3 and wav
2. display offline htm pages
3. play mpg, wmv or avi (mediaplayer component)

Doe's LCL have components that support it (if not when it is expected)?

Is it possible to import activeX contols like in Delphi?
Is it possible to execute winapi functions?

Sorry for my bad english.

Bart

  • Hero Member
  • *****
  • Posts: 5713
    • Bart en Mariska's Webstek
Re: Delphi > Lazarus htm, mp3, avi, jpeg
« Reply #1 on: March 24, 2006, 11:48:02 am »
Quote from: "klodovik"
Hi,
I used Delphi and I will use Lazarus in near future.

Good for you, exactly as I plan to do...
Quote from: "klodovik"

Is it possible (and how) with Lazarus to:
1. play mp3 and wav
2. display offline htm pages
3. play mpg, wmv or avi (mediaplayer component)

As of yet, Lazarus does not have a mediaplayer object...
On Windows you can simply ShellExecute the file though (see below).
Quote from: "klodovik"

Is it possible to execute winapi functions?

Yes it is. You can do stdcall's to windows dll's
See how this is implemented in windows.pas.
(Notice how it is only declared once in the Interface section, as opposed to Delphi that declares the function prototype in the Interface section, then does the stdcall to some specific dll in the Implementation section)

The ShellExecute() is not available in windows.pas because it cannot be implemented (yet??) in an OS independent way.
For executing external programs there is the TProcess object (see the wiki about that).

Nothing however can stop you from calling the standard windows library ShellExecute (or some other library), but you will no longer be able to compile your program for other platforms than Windows.

Hope this helps.

Bart

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Delphi > Lazarus htm, mp3, avi, jpeg
« Reply #2 on: March 24, 2006, 03:26:35 pm »
> 1. play mp3 and wav

Yes, see this component:

http://wiki.lazarus.freepascal.org/index.php/ACS

> 2. display offline htm pages

What is a offline htm page?

> 3. play mpg, wmv or avi (mediaplayer component)

Not yet, althought it has being posted recently that it is being developed.

> Is it possible to import activeX contols like in Delphi?

No, the compiler doesn't support this yet.

> Is it possible to execute winapi functions?

Yes, and Lazarus even has multiplatform versions of many winapi calls, to make porting easier. The multiplatform versions are on the LCLIntf unit. On Windows they directly call WinAPI, on other platforms they are implemented with the widgetset of choice.

You can also access winapi directly using the Windows unit. This doesn't work on any place other then Windows, of course.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Delphi > Lazarus htm, mp3, avi, jpeg
« Reply #3 on: March 24, 2006, 03:28:42 pm »
Quote from: "Bart"
The ShellExecute() is not available in windows.pas because it cannot be implemented (yet??) in an OS independent way.
For executing external programs there is the TProcess object (see the wiki about that).


This is incorrect. Windows.pas is a static link to winapi and only works on Windows. Also I'm pretty sure it has ShellExecute.

I think you confused windows.pas with lclintf.pas

Anonymous

  • Guest
RE: Re: Delphi > Lazarus htm, mp3, avi, jpeg
« Reply #4 on: March 24, 2006, 05:42:19 pm »
>> 2. display offline htm pages

>What is a offline htm page?

I use htm pages to display text and images in my program.
In Delphi I use Web browser component (Component> import active X control) and just WebBrowser1.Navigate('page.htm',EmptyParam,EmptyParam,EmptyParam,EmptyParam);
Pages are crypted and aplication decrypt it before showing.

Someone can say it is stupid to display text with images  in that way but I found it is simple and most important I have now thousands pages of text in htm and can not cancel it.

I live in Serbia and time when we could use best sofware free is (un)fortunatly  behind us. I own small "company" (one man show) and have now good business oportunity but I must legalise my products  and it must be done in 3 weeks.

Unfortunatly, it seems that Lazarus can not satisfy my needs for now.  I will have to buy Delphi and if you know that I earn only net $400 per month my interesting in Lazarus is obvious.

Bart

  • Hero Member
  • *****
  • Posts: 5713
    • Bart en Mariska's Webstek
Re: Delphi > Lazarus htm, mp3, avi, jpeg
« Reply #5 on: March 24, 2006, 08:06:40 pm »
Quote from: "sekel"
Quote from: "Bart"
The ShellExecute() is not available in windows.pas because it cannot be implemented (yet??) in an OS independent way.
For executing external programs there is the TProcess object (see the wiki about that).


This is incorrect. Windows.pas is a static link to winapi and only works on Windows. Also I'm pretty sure it has ShellExecute.

I think you confused windows.pas with lclintf.pas


Are you sure about that? As far as I can see it, it does not.

One of my libs has a routine called ExecuteFile, that just calls ShellExecute.
This lib of course has "uses windows" in the uses clause of the Interface section.
On Delphi it compiles, on Lazarus 0.9.12 for win32 it does not.
I had to add this:
Code: [Select]
type HWND = Integer;
     HINST = Integer;

const
  shell32 = 'shell32.dll';

{ ShellExecute() and ShellExecuteEx() error codes }

{ regular WinExec() codes }
  SE_ERR_FNF              = 2;       { file not found }
  SE_ERR_PNF              = 3;       { path not found }
  SE_ERR_ACCESSDENIED     = 5;       { access denied }
  SE_ERR_OOM              = 8;       { out of memory }
  SE_ERR_DLLNOTFOUND      = 32;

{ error values for ShellExecute() beyond the regular WinExec() codes }
  SE_ERR_SHARE                    = 26;
  SE_ERR_ASSOCINCOMPLETE          = 27;
  SE_ERR_DDETIMEOUT               = 28;
  SE_ERR_DDEFAIL                  = 29;
  SE_ERR_DDEBUSY                  = 30;
  SE_ERR_NOASSOC                  = 31;


function ShellExecuteA(hWnd: HWND; Operation, FileName, Parameters,
  Directory: PAnsiChar; ShowCmd: Integer): HINST; stdcall; external shell32 name 'ShellExecuteA';
function ShellExecuteW(hWnd: HWND; Operation, FileName, Parameters,
  Directory: PWideChar; ShowCmd: Integer): HINST; stdcall; external shell32 name 'ShellExecuteW';
function ShellExecute(hWnd: HWND; Operation, FileName, Parameters,
  Directory: PChar; ShowCmd: Integer): HINST; stdcall; external shell32 name 'ShellExecuteA';

to the implementation section of my lib in order to be able to do a ShellExecute and use it's returnvalues.

Well, maybe I'm wrong, but if it is there, is it really in "windows" ? (if not can you point me to where it is then?)

Anyhow, solving it the way I did, learned me how to do winapi calls in Lazarus (so even it it was not necessary after/at all, I had fun doing it), and the example might be of benefit to the original poster...

Bart

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Delphi > Lazarus htm, mp3, avi, jpeg
« Reply #6 on: March 24, 2006, 10:13:23 pm »
Quote from: "Bart"
Are you sure about that? As far as I can see it, it does not.

One of my libs has a routine called ExecuteFile, that just calls ShellExecute.
This lib of course has "uses windows" in the uses clause of the Interface section.
On Delphi it compiles, on Lazarus 0.9.12 for win32 it does not.


I think it is located at ShellAPI unit.

Despite that, windows does is a static link to winapi. It just happens that a part of it is in another unit. Nothing to do with portability.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Delphi > Lazarus htm, mp3, avi, jpeg
« Reply #7 on: March 25, 2006, 12:08:54 am »
Quote from: "Bart"
Anyhow, solving it the way I did, learned me how to do winapi calls in Lazarus (so even it it was not necessary after/at all, I had fun doing it), and the example might be of benefit to the original poster...


Yes, knowing how to do that is very important if you plan to use third-party dlls or .so files =)

 

TinyPortal © 2005-2018