Autor Beitrag
lblbw
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 122

Win XP, Win 7
Delphi7 Enterprise
BeitragVerfasst: So 04.05.08 16:31 
Hallo,

ich habe folgendes Problem:

Ich lese mit Hilfe von Gausi's AudioDatei_Klasse die Bitrate und Samplerate aus. Leider ist es so, das wenn ich sie im Hauptformular anzeigen lassen will, ich folgenden Fehler bekomme:
[Fehler] Unit1.pas(636): Undefinierter Bezeichner: 'kbs'

In der AudioDatei_Klasse habe ich folgendes hinzugefügt:
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:
unit AudioDatei_Klasse;

interface

uses classes, SysUtils, Mp3FileUtils, ATL_WMAFile;

type
    TAudioFile = class
    private
        fInterpret: String;
        fTitel    : String;
        fPfad     : String;
        fDauer    : Integer;
        fkbs      : Integer;
        fhz      : Integer;

        // ...

    public
        property Interpret: String read fInterpret write fInterpret;
        property Titel    : String read fTitel     write fTitel;
        property Pfad     : String read fPfad;
        property Dauer    : Integer read fDauer write fDauer;
        property kbs      : Integer read fkbs write fkbs;
        property hz       : Integer read fhz write fhz;
        property PlaylistTitel: String read GetPlaylistTitel;

        //...

    end;


implementation


// ...

// ================================================
// Objekt kopieren
// ================================================
procedure TAudioFile.Assign(aAudioFile: TAudioFile);
begin
  fInterpret := aAudioFile.fInterpret;
  fTitel     := aAudioFile.fTitel    ;
  fPfad      := aAudioFile.fPfad     ;
  fDauer     := aAudioFile.fDauer    ;
  fkbs       := aAudioFile.fkbs      ;
  fhz        := aAudioFile.fhz       ;
end;

//...

// ================================================
// Audiodaten ermitteln, MP3s
// ================================================
procedure TAudioFile.GetMp3Info;
//...
begin
//...
    // aus den MPEG-Infos
    fkbs     := mpeginfo.bitrate;
    fhz      := mpeginfo.samplerate;
    fDauer   := mpeginfo.dauer;
//...
  MpegInfo.Free;
  Id3v2Tag.Free;
  Id3v1Tag.Free;
end;
// ...
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 04.05.08 17:31 
Wie greifst du denn darauf zu? Es sollte ungefähr so gehen:

ausblenden Delphi-Quelltext
1:
ShowMessage(IntToStr(MyAudiofile.kbs));					

_________________
We are, we were and will not be.
lblbw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 122

Win XP, Win 7
Delphi7 Enterprise
BeitragVerfasst: So 04.05.08 19:32 
Ich greife so darauf zu:

ausblenden Delphi-Quelltext
1:
kbps.Caption:=IntoStr(MeMPPlaylist.PlayingFile.kbs);					
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 04.05.08 19:35 
Eigentlich sollte das schon funktionieren...

Kannst du vielleicht noch den Source der Playlist zeigen? Vielleicht ist da drin ja ein Fehler.
lblbw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 122

Win XP, Win 7
Delphi7 Enterprise
BeitragVerfasst: So 04.05.08 19:44 
Glaube ich kaum, da ich das Original verwende:

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:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
unit Playlist_Klasse;

interface

uses Contnrs, SysUtils, Classes,
     AudioDatei_Klasse, Player_Klasse;

type
  DWORD = cardinal;

  TPlaylistAddItemEvent = procedure(Sender: TObject; NewAudioFile: TAudioFile) of Object;

  TMeMPPlaylist = Class(TMeMPPlayer)
    private
      fPlayingIndex: Integer;
      fPlayingFile: TAudioFile;
      fPlaylist: TObjectlist;

      fOnClear   : TNotifyEvent;
      fOnAddItem : TPlaylistAddItemEvent;

      function GetNextAudioFileIndex: Integer;
      function GetPrevAudioFileIndex: Integer;
      procedure LoadFromM3U(aFilename: String);
      procedure SaveAsM3U(aFilename: String);
    public

      property PlayingFile: TAudioFile read fPlayingFile;
      property PlayingIndex: Integer read fPlayingIndex;
      property OnClear   : TNotifyEvent          read fOnClear    write fOnClear   ;
      property OnAddItem : TPlaylistAddItemEvent read fOnAddItem  write fOnAddItem ;

      constructor Create;
      destructor Destroy; override;

      procedure Add(aAudiofileName:String);
      procedure Play(aIndex: Integer); Overload;
      procedure PlayNext;
      procedure PlayPrevious;
      procedure Clear;

      procedure LoadFromFile(aFilename: String);
      procedure SaveToFile(aFilename: String);
  end;



implementation

constructor TMeMPPlaylist.Create;
begin
  inherited create;
  fPlaylist := TObjectList.Create;
  fPlayingFile := Nil;
end;


destructor TMeMPPlaylist.Destroy;
begin
  fPlaylist.Free;
  inherited Destroy;
end;

// ================================================
// Datei anhand eines Dateinamens der Liste hinzufügen
// ================================================
procedure TMeMPPlaylist.Add(aAudiofileName: String);
var NewFile: TAudioFile;
begin
  NewFile := TAudioFile.Create;
  NewFile.GetAudioInfo(aAudiofileName);
  fPlaylist.Add(NewFile);

  if assigned(fOnAddItem) then
    fOnAddItem(Self, NewFile);
end;


// ================================================
// Einen bestimmten Eintrag abspielen
// ================================================
procedure TMeMPPlaylist.Play(aIndex: Integer);
begin
  if aIndex >= 0 then
    fplayingIndex := aIndex;
  if (fplayingIndex > fPlaylist.Count - 1) and (fPlaylist.Count > 0) then
    fplayingIndex := fPlaylist.Count - 1;  // setzen auf -1 abfangen!!
  if (fplayingIndex >= 0)  and (fPlayingIndex < fPlaylist.Count)  then
    fPlayingFile := TAudioFile(fPlaylist[fplayingIndex]);

  play(fPlayingFile);
end;

// ================================================
// Weiter/Zurück
// ================================================
procedure TMeMPPlaylist.PlayNext;
begin
  Play(GetNextAudioFileIndex);
end;

procedure TMeMPPlaylist.PlayPrevious;
begin
  Play(GetPrevAudioFileIndex);
end;

// ================================================
// Playlist leeren
// ================================================
procedure TMeMPPlaylist.Clear;
begin
  Stop;
  fPlaylist.Clear;
  if Assigned(fOnClear) then
    fOnClear(Self);
  fPlayingFile := Nil;
  fPlayingIndex := 0;
end;


// ================================================
// Hilffunktionen für vor/zurück
// ================================================
function TMeMPPlaylist.GetNextAudioFileIndex: Integer;
begin
  if fPlayingIndex = fPlaylist.Count - 1 then
    result := 0
  else
    result := fPlayingIndex + 1;
end;

function TMeMPPlaylist.GetPrevAudioFileIndex: Integer;
begin
  if fPlayingIndex = 0 then
    result := fPlaylist.Count - 1
  else
    result := fPlayingIndex - 1;
end;


Habe nur die Speicherung und das Laden der Playlist weg gelassen
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 04.05.08 19:47 
Hm. Vielleicht pfuscht da eine veraltete .dcu dazwischen. Lösch die mal und erzeuge das Projekt neu. Ansonsten fällt mir dazu jetzt nichts ein. :nixweiss:

_________________
We are, we were and will not be.
lblbw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 122

Win XP, Win 7
Delphi7 Enterprise
BeitragVerfasst: So 04.05.08 20:11 
Auch wenns grad komisch klingt und ich mich für die Frage schäme: Wie erstelle ich die dcu? Ich steh grad auf dem Schlauch. Naja, ich sollte vielleicht nicht senden und in Delphi programmieren. Habe eben auch die Ansage total vergessen.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 04.05.08 20:23 
user profile iconGausi hat folgendes geschrieben:
Hm. Vielleicht pfuscht da eine veraltete .dcu dazwischen. Lösch die mal und erzeuge das Projekt neu. Ansonsten fällt mir dazu jetzt nichts ein. :nixweiss:

Wie du Dateien löscht weißt du, oder? ;)
lblbw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 122

Win XP, Win 7
Delphi7 Enterprise
BeitragVerfasst: So 04.05.08 20:36 
logisch, das habe ich auch gemacht. Wenn ich dann das Projetk compiliere, sagt er mir:
ausblenden Delphi-Quelltext
1:
[Fataler Fehler] Unit1.pas(8): Datei nicht gefunden: 'AudioDatei_Klasse.dcu'					
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 04.05.08 20:38 
Die Meldung heißt, dass er die Unit nicht finden kann. Hast du vielleicht auch die .pas-Dateien gelöscht? Oder ist sie nicht in dem Pfad, in dem auch dein Projekt gespeichert ist? Vielleicht ist das ja auch ein Hinweis auf dein erstes Problem.
lblbw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 122

Win XP, Win 7
Delphi7 Enterprise
BeitragVerfasst: So 04.05.08 20:42 
In den Projektoptionen (Unterpunkt Verzeichnisse) habe ich ja reingeschrieben, wo er die Dateien finden kann. Nur nimmt er die anschneinend nicht.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 04.05.08 20:47 
Versuch doch mal, die Dateien ins Projektverzeichnis zu kopieren. Das ist sowieso besser - du kannst die Units bearbeiten, ohne das andere Projekte / Versionen davon unbrauchbar werden. Nur fertiggestellte Units kannst du global verwenden. Dieses Verzeichnis musst du dann unter "Suchpfad" aufnehmen. Am besten machst du das dann global unter Tools > Umgebungsoptionen.
lblbw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 122

Win XP, Win 7
Delphi7 Enterprise
BeitragVerfasst: So 04.05.08 20:55 
Ich benutze generell immer nur Projektordner. Darin unterscheide ich sogar noch nach den Versionen. Sprich, wenn eine Version rauskommt, kopiere ich die Dateien, pack Sie in ein anderen Ordner innerhalb des Projektordners und passe dann die Pfade an. So kann ich notfalls an alte Versionen rankommen, bei denen zum Beispiel das Problem noch funktionierte.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 04.05.08 20:57 
Das ist gut, so mache ich das auch.

Aber hast du auch die benötigten MeMP-Units in den Projektordner kopiert? Das war meine ursprüngliche Frage, und wenn du das nicht gemacht hast, solltest du das tun. Vielleicht klappt es dann.
lblbw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 122

Win XP, Win 7
Delphi7 Enterprise
BeitragVerfasst: So 04.05.08 21:02 
ja habe ich. Problem ist gelöst. Ich habe mich eben an einer Version erinnert, bei der ich das drin hatte, dann aber nicht weiterkopiert habe, sondern eine ältere Version als Kopie genommen, weil damals irgendwas nicht mehr funktionierte. Nun funktioniert es jedenfalls. Danke für die Hilfe!