Recent

Author Topic: Player Music  (Read 5312 times)

buiu

  • New member
  • *
  • Posts: 9
Player Music
« on: April 08, 2018, 07:16:48 pm »
I am Brazilian, and I am developing a music player in Lazarus, but it gives an error:


Code: Pascal  [Select][+][-]
  1. unit uMusica;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Buttons;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     BitBtn1: TBitBtn;
  16.     BitBtn2: TBitBtn;
  17.     BitBtn3: TBitBtn;
  18.     BitBtn4: TBitBtn;
  19.     OpenDialog1: TOpenDialog;
  20.     procedure BitBtn1Click(Sender: TObject);
  21.     procedure BitBtn2Click(Sender: TObject);
  22.     procedure BitBtn3Click(Sender: TObject);
  23.     procedure BitBtn4Click(Sender: TObject);
  24.   private
  25.     { private declarations }
  26.   public
  27.     { public declarations }
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.   Player:OleVariant;
  33.  
  34. implementation
  35.  
  36. {$R *.lfm}
  37.  
  38. { TForm1 }
  39.  
  40. procedure TForm1.BitBtn1Click(Sender: TObject);
  41. begin
  42.   if OpenDialog1.Execute then
  43.   begin
  44.     Player:=OleVariant('vlc');
  45.     Player.url:=Olevariant(UTF8Decode(OpenDialog1.FileName));
  46.   end;
  47. end;
  48.  
  49. procedure TForm1.BitBtn2Click(Sender: TObject);
  50. begin
  51.   Player.Controls.Play;
  52.  
  53. end;
  54.  
  55. procedure TForm1.BitBtn3Click(Sender: TObject);
  56. begin
  57.   Player.Controls.Pause;
  58. end;
  59.  
  60. procedure TForm1.BitBtn4Click(Sender: TObject);
  61. begin
  62.   Player.Controls.Stop;
  63. end;
  64.  
  65. end.
                                           

Project ProjetoMusica raised exception class 'External: SIGSEGV'.


Awkward

  • Full Member
  • ***
  • Posts: 133
Re: Player Music
« Reply #1 on: April 08, 2018, 07:28:23 pm »
why you don't check what "Player" going valid after assignment?

buiu

  • New member
  • *
  • Posts: 9
Re: Player Music
« Reply #2 on: April 08, 2018, 07:37:04 pm »
I do not know how to do this, I'm a beginner.

buiu

  • New member
  • *
  • Posts: 9
Re: Player Music
« Reply #3 on: April 08, 2018, 07:48:32 pm »
Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Buttons,ComObj;
                                                             

Code: Pascal  [Select][+][-]
  1. procedure TForm1.BitBtn1Click(Sender: TObject);
  2. begin
  3.   if OpenDialog1.Execute then
  4.   begin
  5.     Player:=CreateOleObject('vlc-player');
  6.     Player.url:=Olevariant(UTF8Decode(OpenDialog1.FileName));
  7.   end;
  8. end;  

umusica.pas(44,13) Error: Identifier not found "CreateOleObject"

Please, can someone help me?
« Last Edit: April 08, 2018, 08:03:51 pm by buiu »

soerensen3

  • Full Member
  • ***
  • Posts: 213
Re: Player Music
« Reply #4 on: April 08, 2018, 09:04:07 pm »
Code: Pascal  [Select][+][-]
  1. uses ComObj;
Add ComObj to your uses section.
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

buiu

  • New member
  • *
  • Posts: 9
Re: Player Music
« Reply #5 on: April 08, 2018, 09:46:46 pm »
utocadordemp3.pas(7,6) Fatal: Cannot find unit ComObj used by uTocadorDeMP3 of the Project Inspector.

Use Linux OpenMandriva LX3

soerensen3

  • Full Member
  • ***
  • Posts: 213
Re: Player Music
« Reply #6 on: April 08, 2018, 10:35:01 pm »
That's Windows only! See the unit is in the pascal sources under "packages/winunits-base/src".
https://github.com/graemeg/freepascal/blob/master/packages/winunits-base/src/comobj.pp

Maybe that helps:
http://wiki.freepascal.org/Video_Playback_Libraries
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

metis

  • Sr. Member
  • ****
  • Posts: 300
Re: Player Music
« Reply #7 on: April 09, 2018, 04:45:26 pm »
@buiu

Obviously, You want to make a VLC-Player (= Audio & Video).
-> Why don't You use the Components, that come with Lazarus ?

Package: lazvlc: TLCLVLCPlayer, TVLCMediaListPlayer.

For Audio, only, see here:
http://wiki.freepascal.org/Multimedia_Programming
-> GoTo: "Playing Sounds"
« Last Edit: April 09, 2018, 04:47:03 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

 

TinyPortal © 2005-2018