Autor Beitrag
Apollo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 125

Windows 7
Delphi 3 Prof., Delphi 2005
BeitragVerfasst: Mi 16.07.08 12:59 
Hallo Delphianer,

mit meiner neuen, selbestgemachten Komponente soll man die Lautstärke von TMediaplayer verändern können. Hier der Code
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
 unit Component1; 

interface 

uses 
  SysUtils, Classes, mmsystem, mplayer, Windows; 

   const 
   MCI_SETAUDIO = $0873; 
   MCI_DGV_SETAUDIO_VOLUME = $4002; 
   MCI_DGV_SETAUDIO_ITEM = $00800000; 
   MCI_DGV_SETAUDIO_VALUE = $01000000; 
   MCI_DGV_STATUS_VOLUME = $4019; 

   type 
   MCI_DGV_SETAUDIO_PARMS = record 
     dwCallback: integer; 
     dwItem: integer; 
     dwValue: integer; 
     dwOver: integer; 
     lpstrAlgorithm: PChar; 
     lpstrQuality: PChar; 
   end; 
type 
   MCI_STATUS_PARMS = record 
     dwCallback: integer; 
     dwReturn: integer; 
     dwItem: integer; 
     dwTrack: integer; 
   end; 


type 
  TMediaplayerVolume = class(TComponent) 
  private 

      FVolume: integer; 
  FMediaplayer: TMediaplayer; 

  //function MPGetVolume(MP: TMediaPlayer): Integer; 
    { Private-Deklarationen } 
  protected 
    

    { Protected-Deklarationen } 
  public 
      
  function GetVolume : integer; 
    { Public-Deklarationen } 
  published 
  property Volume : integer  read    FVolume  write FVolume; 
  property Mediaplayer: TMediaplayer  read    FMediaplayer  write FMediaplayer; 
    { Published-Deklarationen } 
  end; 

procedure Register; 
procedure MPSetVolume(MP: TMediaPlayer; Volume: Integer) ; 
// procedure GetVolume; 


implementation 

procedure Register; 
begin 
  RegisterComponents('LPI', [TMediaplayerVolume]); 
end; 

function GetVolume : integer; 
begin 
MPSetVolume(FMediaPlayer, FVolume) ; 
end; 

  procedure MPSetVolume(MP: TMediaPlayer; Volume: Integer) ; 
var 
   p: MCI_DGV_SETAUDIO_PARMS; 
begin 
   p.dwCallback := 0; 
   p.dwItem := MCI_DGV_SETAUDIO_VOLUME; 
   p.dwValue := Volume; 
   p.dwOver := 0; 
   p.lpstrAlgorithm := nil; 
   p.lpstrQuality := nil; 
   mciSendCommand(MP.DeviceID, MCI_SETAUDIO, MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM, Cardinal(@p)) ; 
end; 

function MPGetVolume(MP: TMediaPlayer): Integer; 
var 
   p: MCI_STATUS_PARMS; 
begin 
   p.dwCallback := 0; 
   p.dwItem := MCI_DGV_STATUS_VOLUME; 
   mciSendCommand(MP.DeviceID, MCI_STATUS, MCI_STATUS_ITEM, Cardinal(@p)) ; 
   Result := p.dwReturn; 
end; 



end.



In der function
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function GetVolume : integer; 
begin 
MPSetVolume(FMediaPlayer, FVolume) ; 
end;


kennt Delphi FMediaplayer und FVolumen nicht . Dabei habe ich sie hier doch deklerirt
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
private 

      FVolume: integer; 
  FMediaplayer: TMediaplayer; 

  //function MPGetVolume(MP: TMediaPlayer): Integer; 
    { Private-Deklarationen } 
  protected 
    

    { Protected-Deklarationen } 
  public 
      
  function GetVolume : integer; 
    { Public-Deklarationen } 
  published 
  property Volume : integer  read    FVolume  write FVolume; 
  property Mediaplayer: TMediaplayer  read    FMediaplayer  write FMediaplayer; 
    { Published-Deklarationen } 
  end;


Hoffe es ist alles einleuchtend. Danke im voraus

mfg Poseidon

[edit]Hat's zum Glück noch im zwichenspeicher

_________________
Im Zweifelsfall immer das Richtige tun


Zuletzt bearbeitet von Apollo am Mi 16.07.08 14:37, insgesamt 1-mal bearbeitet
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Mi 16.07.08 13:12 
Kerle, Kerle. So was macht man nicht ! Höchstens als Egoist. :twisted: :mahn: Aber das hier kann so leicht keiner editieren. Wer die Frage noch gelesen hat und auch vor solchen Fragen steht : er hatte die Properties als private deklariert und dann versucht mit globaler Prozedur darauf zuzugreifen. Zugewiesen hat er sie auch nirgends. Üblicherweise verwendet man dazu Get/Set-Methoden und das ganze muss sich innerhalb der Komponente abspielen. Glaube, es waren noch mehr Fehler drin, aber die kann ich nun ja nicht mehr sehen.

_________________
Gruß
Hansa
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 16.07.08 13:56 
Dafür ist die Erle dick geworden :lol:

_________________
Markus Kinzler.
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Mi 16.07.08 14:23 
Welche Erle ? :shock: Das habe ich nicht mal in Heilbronn gehört. :mrgreen: Der Sack Reis ist jedenfalls zu spät umgefallen. :lol:

_________________
Gruß
Hansa